How to get cell value of gridview in asp.net C# in text box
I have one gridview in that there are 4 columns namely "User ID","Description","Display Password","Change Password". I have put an Image Button in Change Password Column for each cell. Below the Gridview there are 3 text boxes. When I click on Change Password, the User ID of that particular row should be displayed in text box 1. How to do this in asp.net with C# and back end is MySql DB server.
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.

Krishna GaradRank #191 · 12.8K reputationPosted May 30, 2012, 8:58 PM EDT
in button click event
imagebutton_Click(....)
{
ImageButton btndetails = sender as ImageButton;
GridViewRow gvrow = (GridViewRow)btndetails.NamingContainer;
txtID.Text = gvrow.Cells[0].Text;
txtname.Text = gvrow.Cells[1].Text;
txtsomeone.Text = gvrow.Cells[2].Text;
}
Abumiyan Muqri43 reputationPosted May 30, 2012, 9:54 PM EDT
Thanks for replying... Bt still i m getting error at
txtID.Text = gvrow.Cells[0].Text; step.
when i m typing this line in my code it is not giving any option of "Cells", instead giving "CellSpacing" and "CellPadding" . what to do now?
Please Help..