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
table.
Nov 18 '05 #1
2 2018
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...
2
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...
0
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...
0
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...
0
Oralloy
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++...
0
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...
0
BLUEPANDA
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...
1
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...
1
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...
0
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.