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

When using programmatic binding how do I get a key value

1 Answer 14 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Fred
Top achievements
Rank 1
Fred asked on 30 Aug 2019, 05:08 PM

Hi,

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?

1 Answer, 1 is accepted

Sort by
0
Attila Antal
Telerik team
answered on 04 Sep 2019, 03:55 PM

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.
Tags
Grid
Asked by
Fred
Top achievements
Rank 1
Answers by
Attila Antal
Telerik team
Share this question
or