如何求和Gridview的列并在总和的Baisis上验证?
问题描述:
我想在gridview中使用coulmn。如果Sum大于1,则用户不应该向gridview添加新行。
I want make sum of coulmn in gridview . if Sum becomes greater than 1 User should not be able to add new row to the gridview.
答
Hi Nice,
Hi Nice,
int tot = 0;
protected void Dg_Source_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
tot = tot + Convert.ToInt32(e.Row.Cells["ColumnName"].Text);
lblSum.Text = tot.ToString();
}
}