Register
|
Articles
|
Questions
|
Projects
|
Asp.Net Tips
|
Free Magazines
|
Tutorials
|
Search
|
Write to us
|
Login
Search
Articles
Asp.Net 2.0
AJAX
ADO.Net
C#
Javascript
Books
Asp.Net 2.0
AJAX
ADO.NET
C#
JavaScript
MS SQL Server
SilverLight
VB.NET
XML
Web Service
Resources
Asp.Net News
Downloads
Free Tech Magazines
Asp.Net Web Hosting
Archives
Softwares
Newsletter
Suggest Us
Link to Us
Feeds Subscription
Articles
Questions & Answers
Tips & Tricks
How to Use More than One DataKeyNames in Asp.Net 2.0 GridView
Posted by
Moderator1
on
2/15/2008 8:01:29 PM
8131
Views
DataKeyNames is a property to define Read-only primary key like fields in a GridView control. We can also add some more fields to this property separated by commas.
For example, if 'CusCode' is the primary key and you want 'CusType' as a readonly field, you can assign the GridView control's DataKeyNames property as CusCode,CusType.
To retreive the value from the GridView control in RowDataBound event or any other event of the GridView control, use the below syntax.
To take Field 1, use GridView1.DataKeys[e.Row.RowIndex][0].ToString()
To take Field 2, use GridView1.DataKeys[e.Row.RowIndex][1].ToString()
To take Field n, use GridView1.DataKeys[e.Row.RowIndex][n-1].ToString()
Happy Codings..
Post New Tips/Tricks
View all Tips/Tricks
Featured Resources:
Sexy Web Design - Free 71 Page Preview!
An easy-to-follow guide that reveals the secrets of how to build your own breathtaking web interfaces from scratch.
Website Magazine
A free magazine offering practical advice and helpful tools from industry experts to help any website achieve Internet success.
100% Free Subscription until Stock lost.
View complete list.
Sponsored by
Home
About us
Contact Us
Links
Advertise
Privacy Policy
Copyright ©
2012
. www.AspdotnetCodes.com. All rights reserved.