Click here to Skip to main content
15,890,690 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
binding of selected row in gridview to textboxes

C#
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
{
     clear();
     LinkButton myButton = GridView1.SelectedRow.Cells[0].Controls[0] as LinkButton;
     if (myButton != null)
     {
         txtName.Text = myButton.Text;
     }
     txtAddress.Text = GridView1.SelectedRow.Cells[1].Text; ;
     txtEmailId.Text = GridView1.SelectedRow.Cells[2].Text; ;
     txtPhoneNumber.Text = GridView1.SelectedRow.Cells[3].Text; ;
}

protected void btnDelete_Click(object sender, EventArgs e)
{
     //i want to select select rowIndex of selected gridviewrow
}
Posted
Updated 25-Jul-13 18:49pm
v3
Comments
Sergey Alexandrovich Kryukov 26-Jul-13 0:48am    
What exactly do you mean by "grid view"? Exact fully-qualified type name please. And better tag the UI library or application type you are using.
—SA
Thanks7872 26-Jul-13 0:49am    
This is not a question. What you want to do? Where are you stuck? Is there any error? If yes,at which line? Elaborate your question in order to help you.

Hello Friend,

You can find the selected index of Row using

C#
GridView1.SelectedIndex


property of your gridview. RowIndex is starting from 0 to N, first row is index as 0.
 
Share this answer
 
 
Share this answer
 
Hi,

int currentRow = dataGridView1.CurrentCell.RowIndex;
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900