Query regarding rowdatabound event in gridview asp.net/C#
When u have a gridview(lets say gridview1) and u associate a开发者_如何学Gon event
OnRowDataBound = "gridView1_RowDatabound"
and u usually start the event method as follows
protected void gridView1_RowDatabound(object sender, GridViewRowEventArgs e){
if (e.Row.RowType == DataControlRowType.DataRow){
do something..
}
}
Why do u have to check again if the row is data row, as i understand it gridview1_rowdatabound event occurs only when the rows are getting bound by the datasource u supplied. Why do u perform again this additional checking ?
Can u elucidate it for me ?
Thanks in anticipation
This is to be able to perform different actions based on the row type:
A row can be a 'header' row or a normal 'data' row for example.
The DataControlRowType
enum gives you a pretty good idea what types of rows might appear:
public enum DataControlRowType
{
Header,
Footer,
DataRow,
Separator,
Pager,
EmptyDataRow
}
精彩评论