What is difference between RowIndex and DataItemIndex?

jams picture jams · May 17, 2011 · Viewed 7.4k times · Source

In gridview’s RowDataBound event has e.Row.RowIndex and e.Row.DataItemIndex properties.
Please tell me in easily understandable answer, what is difference between them?
In which situation we should use which one?

Answer

jams picture jams · May 17, 2011

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.