GridView RowDataBound Get DataSource By Row
When using RowDataBound (the GridView’s method) and want to get the data by row. Because RowDataBound work on row by row when initial GridView. How to get data from datasource in method RowDataBound ? Use Eval() method will help you
protected void gvView_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
_SumTotal += Convert.ToInt32(DataBinder.Eval(e.Row.DataItem, “Total”));
}
}// “Total” is a data field in database
// _SumTotal is a global valuable on this page
In this example you can get all total summary in gridview datasource.
Related posts:
- Method Post on Code Behide with asp.net การส่งข้อมูลระหว่าง page สามารถทำได้ 2 วิธี 1. get method 2. post...
Related posts brought to you by Yet Another Related Posts Plugin.