try this
protected void imgBtnEdit_Click(object sender, ImageClickEventArgs e)
{
GridViewRow row = ((Control)sender).Parent.NamingContainer as GridViewRow;
string key = GridStudent.DataKeys[row.RowIndex].Value.ToString();
Response.Redirect("~/Admin/EditUser.aspx?stcode=" + key);
}
Formatting the sql Query string is
vulnerable to
SQL Injection[
^] attacks
always use
Parameterized queries to prevent SQL Injection Attacks in SQL Server[
^]
SqlCommand sqlCmd = new SqlCommand("SELECT * from Student where St_Code=@code", con);
sqlCmd.Parameters.AddWithValue("@code", usercode);
as per comments its no point of getting the count from the table and trying to populate in the textbox, it will throw column not found error, replace it with the desired columns or just add * to the selection .