Solved

Datagrid's datakey field

Posted on 2003-11-19
3
1,364 Views
Last Modified: 2008-02-01
How does the datagrid's datakeyfield property support for composite keys? thanks in advance...
0
Comment
Question by:rxraza
3 Comments
 
LVL 4

Accepted Solution

by:
ainapure earned 100 total points
ID: 9782949
I do not think datekeyfield property supports composite keys. I have used a lot of datagrids lately in one of my project, and the easiest way i worked around was to create a surrogate key in the database. So, for eg. say if your clientid and orderid makes up a unique row, i inserted a new column client_orderid which is an autoincremented.. and then i used this new column as a datakeyfield in datagrid.

-amit

0
 

Author Comment

by:rxraza
ID: 9788570
I would love to do that, but the thing is we do not want to change the database design just to accomodate the datakey feature of the grid. I would rather prefer to pass values through hidden fields or bound columns. Anyways, thanks for your help.
0
 
LVL 1

Expert Comment

by:ferguslogic
ID: 12915161
don't modify the DB design..instead concatenate the two fields in your select statement and put these combined fields into a single DataGrid column.
Then set your datakeyfield to this column.

That is the best solution as the datagrid does not support composite keys.  My understanding is that ASP.net 2.0 will have a successor control (GridView I believe) which will support this composite key functionality.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:  The Exchange of information …
I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question