Solved

What is the DataKeyField in a datalist

Posted on 2006-07-20
4
3,306 Views
Last Modified: 2008-02-01
What is purpose of DataKeyField in a datalist?
0
Comment
Question by:johnywhite
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 6

Accepted Solution

by:
e1v earned 300 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 200 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on www.johnchapman.name could not pull conte…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…

691 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