Hello,
I just found a problem with my gridview. It includes the line command 'Select', which when clicked sends the user to another screen using the record id from the gridview; However, when I use the builtin sorts for each column heading in the gridview after I sort, if I use the 'Select' command it uses the Record Id of the record that was in the spot prior to the sort. It's like the select column does not sort along with the rest of the gridview.
Below is the code: Any help is appreciated. Also, I had a routine I was going to use, but could not get to work. It is a rowcommand procedure, and perhaps this is my problem.
I tried assigning a cell to use to pass the Record id to another screen. but I get an error stating that (e.item.cells(1).text) ...e.items is not a member gridviewcommand arguments. So instead I use SelectedIndexChanged event...is this the problem?
*** This procedure is commented out because of the compilation error. How can I reference cell 1? Protected Sub MyGridView_RowCommand(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCommandEventArgs) Handles MyGridView.RowCommand
' Dim strRecId As String
' If e.CommandName = "Select" Then
' strRecId = (e.item.cells(1).text) '****** compilation error on this line
' Response.Redirect("RecordActions2.aspx?RecId=" & strRecId)
' End If
End Sub
**** in its place I use this ....but row.cell(1).text is the original data prior to the sort!
Protected Sub MyGridView_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyGridView.SelectedIndexChanged
Dim strRecId As String
Dim row As GridViewRow = MyGridView.SelectedRow
strRecId = row.Cells(1).Text
Response.Redirect("RecordActions2.aspx?RecId=" & strRecId)
End Sub
Thanks