When using programmatic binding how do I get a key value

2 posts, 0 answers
  1. Fred
    Fred avatar
    2 posts
    Member since:
    Aug 2019

    Posted 30 Aug 2019 Link to this post


    I have been trying to use programmatic binding based on the following demo https://demos.telerik.com/aspnet-ajax/grid/examples/data-binding/client-side/programmatic/defaultcs.aspx but have been having a problem in getting the key value back into the asp.net code behind.


    The code is (effectively) the same as the example except I am binding to an entity that has a Guid as a key rather than the EmployeeId in the example and I have added a "delete" button using the following

              <telerik:GridButtonColumn UniqueName="DeleteButtonColumn" ButtonType="ImageButton" CommandName="Delete" ConfirmText="Are you sure?" ConfirmDialogType="Classic" ConfirmTitle="Are you sure?" />

    I have set up the DataKeyNames and ClientDataKeyNames in the MasterTableView to be DataKeyNames="GUID" and ClientDataKeyNames="GUID"

    In the code behind I have added an ItemCommand event that gets called, however

    (GridDataItem)e.Item.GetDataKeyValue("GUID") is blank

    (GridDataItem)e.Item.KeyValues contains "{GUID:""""}"


    Can I use programmatic binding method with a GridButtonColumn with type ImageButton in this way?

  2. Attila Antal
    Attila Antal avatar
    520 posts

    Posted 04 Sep 2019 Link to this post

    Hi Fred,

    Accessing the Items, Keys, values and controls in the Code behind can be done for the RadGrid which is bound on server side. In case you have implemented the Client-Side programmatic binding, then you would need to use the Client-Side APIs to work with the grid. 

    Here is the article that describes the way you can access items in client-side code: Accessing Cells and Values in Client-Side Code

    Related articles that might want to check:


    Kind regards,
    Attila Antal
    Progress Telerik

    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Back to Top