ButtonColumn

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

David Lloyd

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?
 

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