There are a few ways to do this:
The first way I am going to show you is an easy workaround, although not the most professional fix.
In the aspx file, place:
<asp:commandfield headertext="Edit/View" showselectbutton="True" xmlns:asp="#unknown">
inside of your gridview.
Then add
onselectedindexchanged="GridView1_SelectedIndexChanged"
into your asp gridview declaration.
Like so
<asp:gridview id="GridView1" runat="server" datasourceid="SqlDataSource1" cssclass="GridView" xmlns:asp="#unknown">
AllowPaging="True" AllowSorting="True"
AutoGenerateColumns="False"
BorderStyle="Ridge" BorderWidth="2px"
OnRowCommand="GridView1_RowCommand"
onselectedindexchanged="GridView1_SelectedIndexChanged" ></asp:gridview>
In the code behind part create this function for the GridView1_SelectedIndexChanged.
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
{
int index = GridView1.SelectedIndex;
Session["selectedId"] = GridView1.Rows[index].Cells[1].Text;
TabContainer1.ActiveTabIndex = 2;
}
I was using this inside of a TabContainer. If you want to change it to another aspx page replace TabContainer1.ActiveTabIndex = 2; with Response.Redirect("~/yourOtherPage.aspx"); or you can also use ServerTransfer, I believe, although I am not familiar with that method.
You can create Session variables to store the data in. Then during the page load of your other page, check these session state variables to see if they have values. If they do you can insert them into textfields to edit.
Also, GridView1.Rows[index].Cells[1].Text; is used to access the values in the gridview at specific locations. Cells[#] is which column of the gridview you want to access.
The Second Option is to follow the example in Ashrafur Rahaman's article
Editable GridView in ASP.NET 2.0, which is a more professional solution then the above.
His example is a good starting place, although it might take you a little bit more time to study and get through the entire article it is worth knowing and easy to add to once you understand how a gridview works. His example will show you how to create these commands once inside of them you will access the information, save it, and change pages like above.
For a more thorough look at how to access items in a gridview check out azamsharp's article at
Accessing the different controls inside a GridView control.
I hope this helps.