Solved

What is the DataKeyField in a datalist

Posted on 2006-07-20
4
3,299 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 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

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 (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) 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