I am displaying a gridview containing an UPDATE button. On clicking the button i need to redirect to another page. Here I am unable to find the row index of a clicked record button.
If i find it then i can get the details of that record and direct to another page.
I tried this but did'nt work...
Expand|Select|Wrap|Line Numbers
- if (e.CommandName.Equals("UPDATE"))
- {
- int x = GridView1.SelectedIndex;
- string key;
- // my primary key ( in column 2) to get that record
- key = GridView1.Rows[x].Cells[2].Text;
- string query;
- query = "select * from tblStudentDetails1 where AdmissionNumber='" + key + "'";
- SqlConnection objCon1 = new SqlConnection(con);
- SqlDataAdapter objDa1 = new SqlDataAdapter(query, objCon1);
- DataTable objDt1 = new DataTable();
- objDa1.Fill(objDt1);
- Session["students"] = objDt1;
- Response.Redirect("admissionPage.aspx");
- }