473,405 Members | 2,294 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

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

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.
Nov 18 '05 #1
2 2058
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

"Alex" <no****@nospam.com> wrote in message
news:O5**************@TK2MSFTNGP10.phx.gbl...
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.

Nov 18 '05 #2
Hi

Try adding all yo columns in code-behind instead of html ... that is add all columns to yo datagrid programatically
Nov 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: J. Ormaetxe | last post by:
Hello, I am developing a Datagrid thar insert, delete and update rows in a Table. This table has got 2 fields that are primary key. How can i detect which row is selected to delete?? Thanks, ...
7
by: Andy Sutorius | last post by:
Hi, I have a datalist with a asp:button. I have onitemcommand firing when the button is clicked. I am attempting to get the datakey of the button that was clicked. I can retrieve a specific...
3
by: Eustice Scrubb | last post by:
When deleting in a Datagrid, I'm using a Datakey to reference the deletion since the specific table I'm deleting from doesn't have a index or ID for each entry. Sub myDataGrid_Delete(ByVal...
7
by: Joel Reinford | last post by:
I am looking for a way to set the selectedindex of a datagrid based on the datakey value. For example given this grid with a datakey of OrderID: OrderID Item 54 A 98 ...
1
by: nate axtell | last post by:
I have a custom class with a Private DataTable member and a Public Property that returns this DataTable in its Get call. Is the DataTable that is returned from the Property's Get a reference to...
1
by: mike | last post by:
i'd like to get datakey of GridView So i write code like below but it wasn't work well. how should i do? protected void BookGridView_RowDataBound(object sender, GridViewRowEventArgs e) { int...
1
by: Mark Richards | last post by:
I posted this earlier, and got no response. Basically I need to be able to grab a value from one of the fields in a gridView to populate a dropdown in another column of the gridview: I have a...
2
by: Rod | last post by:
While working with a datagrid I have a value for the datakey, from this I want to find the ItemIndex. How please? many thanks in advance.
5
by: jrobbins | last post by:
public IEnumerable<AuthorizationObjectClass> GetEmployeeNoAuthorizations(SqlInt32 PersonnelNumber) { DataSet ds; AuthorizationObjectClass auth = new...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.