I'm assuming that by stating "[...]click the 2 rows[...]" you actually mean "click the 2nd row"; at least, this is what your last snippet suggests, since it shows only the values of the 2nd row (on a little side note: the ID's wrong there; it should be 7890
).
The following code snippet shows a GridView
which allows the selection of a single row, and uses an event handler in the code-behind to set the text of each TextBox
to the according value in the selected row:
Page.aspx:
<asp:GridView runat="server" ID="gridView" OnSelectedIndexChanged="gridview_SelectedIndexChanged" AutoGenerateSelectButton="true"></asp:GridView>
Event handler in the code-behind file Page.aspx.cs:
void gridview_SelectedIndexChanged(object sender, EventArgs e)
{
var grid = sender as GridView;
if (grid == null) return;
//Cell[0] will be the cell with the select button; we don't need that one
Textbox1.Text = grid.SelectedRow.Cell[1].Text /* 2 */;
Textbox2.Text = grid.SelectedRow.Cell[2].Text /* Ravi */;
Textbox3.Text = grid.SelectedRow.Cell[3].Text /* 7890 */;
}