This is a migrated thread and some comments may be shown as answers.

DataKeyName property not found

3 Answers 78 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Kashif Akram
Top achievements
Rank 1
Kashif Akram asked on 10 Oct 2011, 12:42 PM
Dear Support ,
                          Just returning from extensive use of Telerik ASP.Net Grid :)  I  am unable to find DataKeyNames property in WinForms GridView . Kindly do let me know how I can find and use this in WinForms GridView.I am using Telerik controls version Q3 2010

Regards

3 Answers, 1 is accepted

Sort by
0
Svett
Telerik team
answered on 13 Oct 2011, 09:01 AM
Hello Kashif,

There is no such property in the WinForms. Could you share with us more information regarding your scenario? What are you trying to achieve with RadGridView for Winforms? This information will allow me to assist you further.

Regards,
Svett
the Telerik team

Q2’11 SP1 of RadControls for WinForms is available for download (see what's new); also available is the Q3'11 Roadmap for Telerik Windows Forms controls.

0
Kashif Akram
Top achievements
Rank 1
answered on 16 Oct 2011, 01:19 PM
Dear Team,
                    I was trying to achieve same work which I did in Telerik ASP.net Grid.i.e. Retrieve bounded record primary key throught DataKeyName property and perfrom delete , update and view record information .
0
Jack
Telerik team
answered on 13 Jan 2012, 05:58 PM
Hi Kashif,

Please accept our apologies for the delayed reply. We had an issue which prevented us from seeing your post in our system. Here is the answer to your question:

When using RadGridView, you can access cell values by using the Cells collection of GridViewRowInfo. Consider the code snippet below:
object value = this.radGridView1.Rows[2].Cells["ID"].Value;

However, if you want to access the underlying data item directly, you can do this by using the DataBoundItem property:
object dataBoundItem = this.radGridView1.Rows[2].DataBoundItem;

Finally, when your data source is a DataTable, you can get the primary key names by using the following code:
DataTable table = this.radGridView1.DataSource as DataTable;
string[] primaryKeyNames = new string[table.PrimaryKey.Length];
for (int i = 0; i < primaryKeyNames.Length; i++)
{
    primaryKeyNames[i] = table.PrimaryKey[i].ColumnName;
}

I hope this helps.
 
All the best,
Jack
the Telerik team

SP1 of Q3’11 of RadControls for WinForms is available for download (see what's new).

Tags
GridView
Asked by
Kashif Akram
Top achievements
Rank 1
Answers by
Svett
Telerik team
Kashif Akram
Top achievements
Rank 1
Jack
Telerik team
Share this question
or