Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

How to specify the DataKey of a GridView

Posted on 2006-06-27
5
Medium Priority
?
501 Views
Last Modified: 2008-01-09
How do I programatically specify the DataKey of a GridView?

With a DataGrid I could use the following:

datagrid1.DataKeyField = "departmentID"

0
Comment
Question by:g-spot
  • 3
  • 2
5 Comments
 
LVL 16

Accepted Solution

by:
Swapnil Piparia earned 500 total points
ID: 16991347
Hi g-spot,
GridView1.DataKeyNames(0) = "departmentID"

Regards,
NetSwap
0
 

Author Comment

by:g-spot
ID: 16991881
Thanks Netswap!
0
 

Author Comment

by:g-spot
ID: 16993011
I'm getting the following error:

"Index was outside the bounds of the array."
0
 
LVL 16

Expert Comment

by:Swapnil Piparia
ID: 16998469
Hi g-spot,
you can do it in other tricky way as following as DataKeyNames only except array of strings.

Dim strKeys As String() = {"departmentID"}
GridView1.DataKeyNames = strKeys
0
 

Author Comment

by:g-spot
ID: 16999325
That's fixed it. Thanks netswap :-)
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
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.…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Kernel Data Recovery is a renowned Data Recovery solution provider which offers wide range of softwares for both enterprise and home users with its cost-effective solutions. Let's have a quick overview of the journey and data recovery tools range he…
Suggested Courses

564 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