GridView with DataTable as data source and RowDataBound

T

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
 
M

Muhammad Naveed Yaseen

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)
{
...
}
 
T

Tim

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top