g-spot
asked on
How to specify the DataKey of a GridView
How do I programatically specify the DataKey of a GridView?
With a DataGrid I could use the following:
datagrid1.DataKeyField = "departmentID"
With a DataGrid I could use the following:
datagrid1.DataKeyField = "departmentID"
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I'm getting the following error:
"Index was outside the bounds of the array."
"Index was outside the bounds of the array."
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
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
ASKER
That's fixed it. Thanks netswap :-)
ASKER