如何在不使用页脚行的情况下计算asp.net网格视图中的列和
本文关键字:net asp 计算 网格 视图 情况下 | 更新日期: 2023-09-27 18:20:47
我有一个GridView
,其中一列显示成本。我想把这笔费用加在一起,并显示为账单金额。在CCD_ 2时,行计费金额应当是CCD_。
我正在使用asp .net c#
。
您应该在rowDataBound
事件中执行此操作,在该事件中,您将能够访问当前绑定的行中的每个cell
,并将值相加为variable
。
另一种方法是直接计算Database
的值
protected void txtUnitPrice_TextChanged(object sender, EventArgs e)
{
try
{
DataSet dset3 = new DataSet();
GridViewRow currentRow = (GridViewRow)((TextBox)sender).Parent.Parent;
TextBox qty = (TextBox)currentRow.FindControl("txtqty");
TextBox qty1 = (TextBox)currentRow.FindControl("txtUnitPrice");
string a = qty.Text;
TextBox totalprice = (TextBox)currentRow.FindControl("txttotal");
totalprice.Text = (Double.Parse(qty1.Text) * Double.Parse(qty.Text)).ToString();
}
catch (Exception ex)
{
}
}