GRIDVIEW HOW TO RETRIVE THE SELCTED FIED .....HOW TO PASS
IN GRIDVIEW HOW TO Retrieve the selected EMP ID using the DataKeyName value and HOW TO pass it to the query .......
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
JAYRAMPosted Jan 23, 2013, 12:18 AM
Rishikesh Kumar SinghPosted Jan 22, 2013, 11:53 PM
Step-2:- then on any event you can find that id with a single line of code
string id = GridView1.DataKeys[e.RowIndex].Value.ToString();
Ex:-
Suppose i am finding out it on RowUpdating event....
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
string id = GridView1.DataKeys[e.RowIndex].Value.ToString(); //this will give you the EMP_ID
}
Pradip PandeyPosted Jan 22, 2013, 11:45 PM
In .cs file
string Name;
Name = this.GridView1.DataKeys[index].Values[1].ToString();
ViewState["ID"] = ID;
}
And now you can pass the value of ViewState in your query string.
Hope it will help.