What is the DataKeyField in a datalist

Posted on 2006-07-20
Last Modified: 2008-02-01
What is purpose of DataKeyField in a datalist?
Question by:johnywhite
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

Accepted Solution

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]

Author Comment

ID: 17154269
Do you have a more detailed explanation or an example perhaps?
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

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());


Author Comment

ID: 17167724
That makes a little more sense.  Thanks.

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 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