How to access DataKeyName Value in a Grid View
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Blocked AccountRank #403 · 6.2K reputationPosted Jan 6, 2008, 6:30 PM EST
You can get the value by using this.
GridView1.DataKeys[0].Value.ToString();
Happy Coding!!
Manju Reddy4 reputationPosted Jan 29, 2008, 10:32 AM EST
You can add fields to the data keys like following
string
[] keys = new string[1];keys[0] =
"Field1";If you are trying to retrive these key values in GridView events like RowUpdating, RowDeleting etc. you can use following code
string str1 = GridView1.DataKeys[e.RowIndex].Value.ToString()
-Manny,
www.helpunzipped.com