<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" OnSelectedIndexChanged="GridView1_SelectedIndexChanged"
DataKeyNames="FirstName,LastName,Address,ID" OnRowCommand="gv_RowCommand">
<Columns>
<asp:CommandField ShowEditButton="True" />
<asp:BoundField DataField="FirstName" HeaderText="First NAme" />
<asp:BoundField DataField="LastName" HeaderText="Last NAme " />
<asp:BoundField DataField="Address" HeaderText="SAddress" />
<asp:BoundField DataField="ID" HeaderText="Identity" />
<asp:ButtonField CommandName="modify" Text="modify" />
</Columns>
</asp:GridView>
On your code behind
protected void gv_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "modify")
{
int index = Convert.ToInt32(e.CommandArgument);
txtFname.Text = gv.DataKeys[index].Values["FirstName"].ToString();
txtLname.Text = gv.DataKeys[index].Values["LastName"].ToString();
txtAddr.Text = gv.DataKeys[index].Values["ID"].ToString();
}
}