how to get field value of selected row in gridview?


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
 
Ad

Advertisements

D

Dan

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?
 
Ad

Advertisements

N

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
 

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

Top