Question

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?

Was it helpful?

Solution

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.

OTHER TIPS

Here's a decent example from MSDN: http://msdn.microsoft.com/en-us/library/bb907626.aspx

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top