Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Datagrid's datakey field

Posted on 2003-11-19
3
Medium Priority
?
1,369 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 200 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

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

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

I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Suggested Courses

824 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