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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
In a recent question ( here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…

776 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