469,898 Members | 1,599 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,898 developers. It's quick & easy.

GridView with DataTable as data source and RowDataBound

Tim
I'm using a GridView with its DataSource property set to a DataTable.
During the RowDataBound event, the first row of the DataTable is
reported as a DataControlRowType.Header instead of
DataControlRowType.DataRow. How do I change this behavior?

Right now, I ignore the RowType and just assume all rows are actually
data rows (which in fact they are). However, this bugs me, so I'm
wondering if any one knows how to "properly" work around this problem.

Thanks in advance.

Tim

Aug 24 '07 #1
2 6951
During the RowDataBound event, the first row of the DataTable is
reported as a DataControlRowType.Header instead of
If it is *Row*DataBound event of *GridView*, then it should report
first row of GridView and not DataTable, which is in fact usually
Header (unless turned off or empty data), and can be many other types
too, like footer,pager, empty row etc.

You may want to place your data row specific code in a conditional
block like following

if(e.Row.RowType == DataControlRowType.DataRow)
{
...
}
Aug 26 '07 #2
Tim
On Aug 25, 8:00 pm, Muhammad Naveed Yaseen <mnyas...@gmail.comwrote:
During the RowDataBound event, the first row of the DataTable is
reported as a DataControlRowType.Header instead of

If it is *Row*DataBound event of *GridView*, then it should report
first row of GridView and not DataTable, which is in fact usually
Header (unless turned off or empty data), and can be many other types
too, like footer,pager, empty row etc.

You may want to place your data row specific code in a conditional
block like following

if(e.Row.RowType == DataControlRowType.DataRow)
{
...

}
Yes, that's what I would expect, but when in the RowDataBound
callback, the row with type Header is actually the first row of the
DataTable, not the header row of the GridView.

If I turn off the header in the GridView's properties, I still get the
first row of the DataTable reported as a header row in RowDataBound.

Thanks for the response.

Tim
Aug 27 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Congero | last post: by
5 posts views Thread by sutphinwb | last post: by
6 posts views Thread by Kevin Attard | last post: by
4 posts views Thread by Ken Wigle | last post: by
4 posts views Thread by Tomasz Jastrzebski | last post: by
1 post views Thread by =?Utf-8?B?V2VzbGV5IERhdmlzLCBHZW5lcmFsIER5bmFtaWNz | last post: by
3 posts views Thread by =?Utf-8?B?SmVu?= | last post: by
3 posts views Thread by David C | last post: by
1 post views Thread by Waqarahmed | last post: by
reply views Thread by Salome Sato | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.