472,374 Members | 1,634 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,374 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
Nov 18 '05 #1
2 2018

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

"Alex" <no****@nospam.com> wrote in message
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

Nov 18 '05 #2

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

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, ...
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...
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...
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 ...
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...
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...
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...
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.
by: jrobbins | last post by:
public IEnumerable<AuthorizationObjectClass> GetEmployeeNoAuthorizations(SqlInt32 PersonnelNumber) { DataSet ds; AuthorizationObjectClass auth = new...
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and efficiency. While initially associated with cryptocurrencies...
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge required to effectively administer and manage Oracle...
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was proposed, which integrated multiple engines and...
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the synthesis of my design into a bitstream, not the C++...
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand. Background colors can be used to highlight important...
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS starter kit that's not only easy to use but also...
by: Johno34 | last post by:
I have this click event on my form. It speaks to a Datasheet Subform Private Sub Command260_Click() Dim r As DAO.Recordset Set r = Form_frmABCD.Form.RecordsetClone r.MoveFirst Do If...
by: ezappsrUS | last post by:
Hi, I wonder if someone knows where I am going wrong below. I have a continuous form and two labels where only one would be visible depending on the checkbox being checked or not. Below is the...
by: F22F35 | last post by:
I am a newbie to Access (most programming for that matter). I need help in creating an Access database that keeps the history of each user in a database. For example, a user might have lesson 1 sent...

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.