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

x
?
Solved

What is the DataKeyField in a datalist

Posted on 2006-07-20
4
Medium Priority
?
3,348 Views
Last Modified: 2008-02-01
What is purpose of DataKeyField in a datalist?
0
Comment
Question by:johnywhite
  • 2
4 Comments
 
LVL 6

Accepted Solution

by:
e1v earned 1200 total points
ID: 17148902
DataKeyField is for specifying key field for each row when databinding, for example customerId. Then you can access the keys with datalist.DataKeys[index]
0
 

Author Comment

by:johnywhite
ID: 17154269
Do you have a more detailed explanation or an example perhaps?
0
 
LVL 96

Assisted Solution

by:Bob Learned
Bob Learned earned 800 total points
ID: 17163024
Here is an example:

Presenting Hierarchical Data in ASP.NET
http://www.asp101.com/articles/jayram/hierarchical/default.asp

If you specify DataKeyField, then when you bind the DataList to the source, then you can do something like this C# example:

  string sQuery = sQuery.Replace("{CUSTOMER_ID}",DataList1.DataKeys[DataList1.SelectedIndex].ToString());

Bob
0
 

Author Comment

by:johnywhite
ID: 17167724
That makes a little more sense.  Thanks.
0

Featured Post

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

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

A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
Loops Section Overview
Screencast - Getting to Know the Pipeline
Suggested Courses

916 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