How to access DataKeyName Value in a Grid View
How to access DataKeyName Value in a Grid View
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.
Manju ReddyPosted Jan 29, 2008, 3:32 PM
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
Blocked AccountPosted Jan 6, 2008, 11:30 PM
You can get the value by using this.
GridView1.DataKeys[0].Value.ToString();
Happy Coding!!