Is it possible to set the DataKey property of a DataGrid manually?

A

Alex

I'm wondering how I can add data to the datakey property of the DataGrid.
It seems to be read only. How can I populate it?
I'm using data bound columns, however do not autogenerate the entire grid
table.
 
T

Teemu Keiski

Hi,

you can set DataKeyField programmatically, but of course if you mean
changing the key value for separate rows (taking it from different column
based on row), then it is not possible. In that case, you'd pick the data
column you need via DataItem property of every DataGridItem (in
ItemDataBound for example).

--
Teemu Keiski
MCP, Microsoft MVP (ASP.NET), AspInsiders member
ASP.NET Forum Moderator, AspAlliance Columnist
http://blogs.aspadvice.com/joteke

I'm wondering how I can add data to the datakey property of the DataGrid.
It seems to be read only. How can I populate it?
I'm using data bound columns, however do not autogenerate the entire grid
table.
 
G

Guest

Hi

Try adding all yo columns in code-behind instead of html ... that is add all columns to yo datagrid programatically
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,534
Members
45,007
Latest member
OrderFitnessKetoCapsules

Latest Threads

Top