Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Asp.Net Gridview Buttonfield get Row Data

I have a Gridview which is binded to a datatable that I created. The data in the table is ever changing.

I added a buttonfield to the Gridview. When clicked I want to send a specific columns value in that row through a link or sent through a function.

How do you go about doing this?

like image 531
user84786 Avatar asked Apr 01 '09 18:04

user84786


People also ask

How to get Cell value of GridView in ASP net on Row command?

Get cell value of GridView in RowCommand event in ASP.Net The row index can be easily determined using the CommandArgument property of GridViewCommandEventArgs object and using the row index, the GridView Row is referenced. Finally using the reference of the GridView Row, the values from the cells are fetched.


1 Answers

I found out how to do it. You set the commandName property to whatever you want to call it inside the properties.

Then if you double click on the button after creating it in design view, it should pop up a function in the code behind page. You can then access the row by doing the following.

protected void gvUsers_RowCommand(object sender, GridViewCommandEventArgs e) {

 int rowNum = int.Parse(e.CommandArgument.ToString());

}

from there you can use the row number to access specific column data.

like image 129
user84786 Avatar answered Sep 20 '22 15:09

user84786