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?
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With