Solved

Datagrid's datakey field

Posted on 2003-11-19
3
1,356 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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
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/…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

707 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now