DataKeyName property not found

4 posts, 0 answers
  1. Kashif Akram
    Kashif Akram avatar
    1 posts
    Member since:
    Mar 2010

    Posted 10 Oct 2011 Link to this post

    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
  2. Svett
    Admin
    Svett avatar
    728 posts

    Posted 13 Oct 2011 Link to this post

    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.

  3. Kashif Akram
    Kashif Akram avatar
    1 posts
    Member since:
    Mar 2010

    Posted 16 Oct 2011 Link to this post

    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 .
  4. Jack
    Admin
    Jack avatar
    2333 posts

    Posted 13 Jan 2012 Link to this post

    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).

Back to Top