In my paginated GridView (contained in an UpdatePanel) bound to ObjectDataSource, I have an OnDataBound event,
protected void GridView1_DataBound(object sender, EventArgs e)
{
foreach (GridViewRow row in GridView1.Rows)
{
// row isn't starting from the first row of current page in mono!
}
}
When running in .NET, I GridView.Rows always give me the ones in the current page (i.e. GridViewRow.DataItemIndex will not be 0 but its correct index into its data source). But on Mono 2.10.8, this gives me 0 regardless of which page I’m viewing!
However, GridView.Rows[0].DataItem returns the same item as .NET. It would appear that there’s a bug in DataItemIndex.
Is there a way to workaround it and achieve the same behavior as .NET on Mono and still maintain compatibility with .NET?
Found a way to achieve this.
This works in both Mono and .NET.