How to grab a column value from a GridView
Okay, I know it's a simple question but obviously I'm just learning. I have a GridView w/5 columns. When the user selects a row I need to get a value of a column in that selected row, and it's not the primary key. I grab the PK by this code:
Protected Sub GridView1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs)
TextBox1.Text = ""
If Page.IsPostBack Then
Dim intIndex As Integer
intIndex = GridView1.SelectedIndex
TextBox1.Text = "You selected " & GridView1.DataKeys(intIndex).Value.ToString()
End If
End Sub
Thanks for your help!
Erik
|