Unable to get value of ButtonField from GridView

Joined
Nov 2, 2007
Messages
1
Reaction score
0
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,968
Messages
2,570,153
Members
46,699
Latest member
AnneRosen

Latest Threads

Top