ButtonColumn

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

On a web form I have a grid, grid1, with a ButtonColumn bound to a field in a
table. When the button is clicked I want do do something with the data view
in the row clicked. How do I retrieve the data in the clicked ButtonColumn?
When I use

GridViewRow selectedRow = GridView1.Rows[index];
TableCell installationName = selectedRow.Cells[1] ;
TextBox1.Text = installationName.Text;

It returns blank text.

How do I get the value in the clicked ButtonColumn?
 
Dave:

I believe in this case the data is bound to a button control rather than the
table cell. You can access the controls of a table cell by using the
Controls collection of the TableCell class, or alternatively by using the
FindControl method of the TableCell class. You code might looking something
like the following:

GridViewRow selectedRow = GridView1.Rows[index];
TableCell installationName = selectedRow.Cells[1] ;
Button myButton =
(Button)installationName.FindControl("MyButtonName");
TextBox1.Text = myButton.Text;

--
David Lloyd
MCSD .NET
http://LemingtonConsulting.com

This response is supplied "as is" without any representations or warranties.


On a web form I have a grid, grid1, with a ButtonColumn bound to a field in
a
table. When the button is clicked I want do do something with the data view
in the row clicked. How do I retrieve the data in the clicked ButtonColumn?
When I use

GridViewRow selectedRow = GridView1.Rows[index];
TableCell installationName = selectedRow.Cells[1] ;
TextBox1.Text = installationName.Text;

It returns blank text.

How do I get the value in the clicked ButtonColumn?
 
Back
Top