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.
Pradip PandeyRank #452 · 5.6K reputationPosted Jan 22, 2013, 6:45 PM EST
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.
Rishikesh Kumar SinghRank #1,250 · 1.4K reputationPosted Jan 22, 2013, 6:53 PM EST
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
}
JAYRAMRank #7,836 · 233 reputationPosted Jan 22, 2013, 7:18 PM EST
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questionsTop experts