What is difference between RowIndex and DataItemIndex?
In gri开发者_如何学JAVAdview’s
RowDataBound
event has e.Row.RowIndex
and e.Row.DataItemIndex
properties.
Use the DataItemIndex
property to determine the index of the DataItem in the underlying DataSet.
Use the RowIndex
property to determine the index of the GridViewRow object in the Rows collection of a GridView control.
e.Row.RowIndex
return the index of the row that is currently under binding
e.Row.DataItemIndex
contains all the data indexes of the rows that is currently under binding.
DataItemIndex is the index of DataItem in the underlying DataSet. YES
RowIndex is the index of Row in the underlying GridView. YES
But there is big a difference
e.g If your girdview has the page size of 10 rows then your RowIndex is always 0-9 for each page but the DataItemIndex will be different when you will go for other pages such as PageIndex 2,3,4 ... On page 2 the DataItemIndex will be between 10-19 but the RowIndex is still 0-9.
Well the difference could be that "e.Row.DataItemIndex" applies to DataItem only; means This property applies only to data rows where as "e.Row.RowIndex" could be for datarow, header row, etc.
RowIndex is the current visible row in the rendered table. DataItemIndex is the actual item's index; they both will show the index of the record in the set of currently displayed records.
精彩评论