I am trying to get the value of a clicked ButtonField in a Gridview to pass to another page. The problem is when I click the text in the ButtonField, it keeps returning an empty string. Can anyone help me with this?
My GridView looks like this:
<asp:GridView ID="gvObligors" runat="server" DataKeyNames="OR_OBLGR_NO,OR_BANK_NO,OR_SYSTEM_IN,OR_LE_SC_IN,ID" AutoGenerateColumns="False" Font-Size="8pt" OnDataBound="gvObligors_DataBound" OnRowCommand="gvObligors_RowCommand">
and the ButtonField looks like this (there are other bound fields, this is just the button field):
<asp:buttonfield buttontype="Link" commandname="Select" headertext="RAV/GRV ID" datatextfield="ID"/>
The code behind that is used to get the value of the clicked item looks like this:
Protected Sub gvObligors_RowCommand(ByVal sender As Object, ByVal e As GridViewCommandEventArgs)
If e.CommandName = "Select" Then
Dim index As Integer = Convert.ToInt32(e.CommandArgument)
Dim selectedRow As GridViewRow = gvObligors.Rows(index)
Dim IDCell As TableCell = selectedRow.Cells(4)
Dim ID As String = IDCell.Text
Response.Redirect("ViewDetail.aspx?ID=" & ID & "")
End If
End Sub
Thanks for any help you can provide.
My GridView looks like this:
<asp:GridView ID="gvObligors" runat="server" DataKeyNames="OR_OBLGR_NO,OR_BANK_NO,OR_SYSTEM_IN,OR_LE_SC_IN,ID" AutoGenerateColumns="False" Font-Size="8pt" OnDataBound="gvObligors_DataBound" OnRowCommand="gvObligors_RowCommand">
and the ButtonField looks like this (there are other bound fields, this is just the button field):
<asp:buttonfield buttontype="Link" commandname="Select" headertext="RAV/GRV ID" datatextfield="ID"/>
The code behind that is used to get the value of the clicked item looks like this:
Protected Sub gvObligors_RowCommand(ByVal sender As Object, ByVal e As GridViewCommandEventArgs)
If e.CommandName = "Select" Then
Dim index As Integer = Convert.ToInt32(e.CommandArgument)
Dim selectedRow As GridViewRow = gvObligors.Rows(index)
Dim IDCell As TableCell = selectedRow.Cells(4)
Dim ID As String = IDCell.Text
Response.Redirect("ViewDetail.aspx?ID=" & ID & "")
End If
End Sub
Thanks for any help you can provide.