I'm a bit confused on how to fix this issue. I have a page that displays a list of vehicles in a gridview that is populate with a datatable from a database. I have a search feature that the user can do to limit the results. So basically they type in a truck number and click search, and it goes and loads the data table with just those records that match and loads the gridview with that table. Each row of the gridview has a Show button.
The problem happens if the user hits the back button on their browser. They are now looking at the unfiltered gridview, but the browser thinks it is filtered. If I click Show on the 10th row, the browser thinks the gridview only has 1 row and throws an index out of range error. Same thing happens if I try to look at the bound datatable.
Both of the below (commented and uncomment through me the index out of range error)
Protected Sub gvVehicles_RowCommand(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCommandEventArgs) Handles gvVehicles.RowCommand
Code:If e.CommandName = "Show" Then Dim oInfo As New clsVehicleInformation Dim oSQL As New clsWPSMD Dim oVehicleSearch As New clsVehicleSearch 'oInfo.strEquipmentID = DirectCast(gvVehicles.DataSource, _ ' Data.DataTable).Rows(Convert.ToInt32(e.CommandArgument) + _ ' (gvVehicles.PageSize * gvVehicles.PageIndex)).Item(0) oInfo.strEquipmentID = gvVehicles.Rows(Convert.ToInt32(e.CommandArgument) + _ (gvVehicles.PageSize * gvVehicles.PageIndex)).Cells(0).Text oSQL.LoadVehicleInfo(oInfo) PopulateVehicleInfo(oInfo) End If End Sub




Reply With Quote