Hi
I have a gridview that is bound to an ObjectDataSource that displays a varying amount of rows depending on some parameters passed to the Objectdatasource. On certain rows I am performing actions on the gridview_rowdatabound event - things like changing the tooltip for a cell depending on data etc. In this code I grab some of the cells returned to the gridview, but not displayed, so that I can use the data to add to the information displayed.
example
-------
Protected Sub gvObj_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles gvObj.RowDataBound
Dim rowPic As String = DataBinder.Eval(e.Row.DataItem, "cat_picture_available")
Dim rowTitle As String = DataBinder.Eval(e.Row.DataItem, "cat_title")
Dim rowDesc As String = DataBinder.Eval(e.Row.DataItem, "cat_desc")
Dim rowCatId As String = DataBinder.Eval(e.Row.DataItem, "cat_id")
Dim rowText As String = e.Row.Cells.Item(1).Text
If rowPic = "Y" Then
e.Row.Cells.Item(0).ToolTip = rowTitle
e.Row.Cells.Item(1).Text = "<a href=""pgDetails.aspx?ID=" & rowCatId & """>" & row1text & "</a>"
Else
e.Row.Cells.Item(0).Text = ""
End If
This works fine until I decided to turn paging on in the gridview control and I get an error on the line:
Dim rowText As String = e.Row.Cells.Item(1).Text
Error displayed is
Specified argument was out of the range of valid values.
Parameter name: index
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
Parameter name: index
If I turn paging back off it works correctly again.
Can anyone help with this problem?
Thanks