Events from controls in a DataGridTemplateColumn

Posted by: bdwest on 7 August 2017, 6:42 am EST

  • Posted 7 August 2017, 6:42 am EST

    I have a group of 5 radio buttons in each cell of a column within a datagrid as shown below. When a button is checked it toggles one of five boolean values in my class to true. That part works fine. I also need to generate a event when any of the 5 radio buttons is changed. Since the radio buttons are embeded in the DataTemplate I can seem to access any of the radio button events. Can someone tell me how to do this, assuming it is possible.



  • Posted 7 August 2017, 6:42 am EST

    Thanks, I had not thought about that option.

  • Posted 7 August 2017, 6:42 am EST

    Hi Brian,

    I believe the simplest way to do that is to put the content of the cell(The radio buttons) into a usercontrol, then each cell will have this user control as the template of the cell. As you can see you can put the logic of the radio buttons in the user control code behind.



  • Posted 9 June 2019, 11:19 pm EST

    I am having problems with DataGrid celltemplate and headertemplate. I have created many datagridtemplatecolumns in the code behind and when I apply both templates my data is not showing up properly.

    Is there any sample for this.

    A dataGrid build in c# with a user control in the CellTemplate and a user control in the HeaderTemplate.

    When I apply only CellTemplate my data is fine but when I apply both templates my data is no good.

    plz help

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels