Y
yer darn tootin
I have a paged datagrid that when built consists of several pages.
On each page there an ID number which is to be sent in a call another
page, like this:
Private Sub dgResults_ItemCommand(ByVal source As System.Object,
ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles
dgResults.ItemCommand
If e.CommandName = "ViewID" Then
Response.Redirect("IDdetail.aspx?ID=" &
e.Item.Cells(2).Text.ToString)
End If
End Sub
Problem is that e.items.cells(2)is always taken from the corresponding
position on page 1. Eg Page one might have a list of ids 2,4,6,8 and
page 10 has ids 3,5,7,9. If I view page 10 and click 9 e.item.cells(2)
is equal to 8
Any suggestions on how to pass the correct ID?
Thanks,
Bob
*******************
The other code used
Page_load
Dim oDT as New DataTable
oDT = oDAL.GetAllID(fielda,fieldb, etc) -- call a sql sproc
If oDT.Rows.Count > 0 Then
dgResults.DataSource = oDT.DefaultView
dgResults.DataBind()
lblTotalRecs.Text = "Total Records: " & oDT.Rows.Count.ToString
Private Sub dgResults_PageIndexChanged(ByVal source As Object, ByVal e
As System.Web.UI.WebControls.DataGridPageChangedEventArgs) Handles
dgResults.PageIndexChanged
dgResults.CurrentPageIndex = e.NewPageIndex
BindGrid()
End Sub
Private Sub BindGrid()
Dim oDV As New DataView
oDV = dgResults.DataSource
dgResults.DataSource = oDV
dgResults.DataBind()
oDV.Dispose()
End Sub
On each page there an ID number which is to be sent in a call another
page, like this:
Private Sub dgResults_ItemCommand(ByVal source As System.Object,
ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles
dgResults.ItemCommand
If e.CommandName = "ViewID" Then
Response.Redirect("IDdetail.aspx?ID=" &
e.Item.Cells(2).Text.ToString)
End If
End Sub
Problem is that e.items.cells(2)is always taken from the corresponding
position on page 1. Eg Page one might have a list of ids 2,4,6,8 and
page 10 has ids 3,5,7,9. If I view page 10 and click 9 e.item.cells(2)
is equal to 8
Any suggestions on how to pass the correct ID?
Thanks,
Bob
*******************
The other code used
Page_load
Dim oDT as New DataTable
oDT = oDAL.GetAllID(fielda,fieldb, etc) -- call a sql sproc
If oDT.Rows.Count > 0 Then
dgResults.DataSource = oDT.DefaultView
dgResults.DataBind()
lblTotalRecs.Text = "Total Records: " & oDT.Rows.Count.ToString
Private Sub dgResults_PageIndexChanged(ByVal source As Object, ByVal e
As System.Web.UI.WebControls.DataGridPageChangedEventArgs) Handles
dgResults.PageIndexChanged
dgResults.CurrentPageIndex = e.NewPageIndex
BindGrid()
End Sub
Private Sub BindGrid()
Dim oDV As New DataView
oDV = dgResults.DataSource
dgResults.DataSource = oDV
dgResults.DataBind()
oDV.Dispose()
End Sub