how to get field value of selected row in gridview?

  • Thread starter Thread starter Dan
  • Start date Start date
D

Dan

Hi,

i have a gridview with the Select command button. When i click on that
select button, i want to get the value of e.g. the first field of that row.
Thanks for help.
Dan

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
DataSourceID="SqlDataSource1" >
<Columns>
<asp:CommandField ShowSelectButton="True" />
.....
</asp:GridView>

Protected Sub GridView1_SelectedIndexChanged(ByVal sender As Object, ByVal e
As System.EventArgs) Handles GridView1.SelectedIndexChanged

???

End Sub
 
thanks, but i didn't find exactly what i want.

i did this: Dim a As String = GridView1.Columns.Item(1).ToString

and this gives me the name of the field, but could you tell me how to get
the value of that field?
 
thanks, but i didn't find exactly what i want.

i did this: Dim a As String = GridView1.Columns.Item(1).ToString

and this gives me the name of the field, but could you tell me how to get
the value of that field?
 
you have to do as follows......

Dim itemSelected As GridViewRow = GridView1.SelectedRow
Dim es As String = itemSelected.Cells(1).Text.ToString

Best Regards...
Natheer Sheriff
 
you have to do as follows......

Dim itemSelected As GridViewRow = GridView1.SelectedRow
Dim es As String = itemSelected.Cells(1).Text.ToString

Best Regards...
Natheer Sheriff
 
Back
Top