RadioButtonList in RadGrid ItemCommand

4 posts, 0 answers
  1. Steven
    Steven avatar
    9 posts
    Member since:
    Oct 2012

    Posted 21 Jan Link to this post

    Can a radiobuttonlist trigger a call to ItemCommand inside a RadGrid.  Below, the button works, but the radiobuttonlist does not hit the event in code behind.

    <telerik:GridTemplateColumn AllowFiltering="false" HeaderText="Approvals" UniqueName="Approvals">
        ItemStyle HorizontalAlign="Left" Width="140" />
        <HeaderStyle HorizontalAlign="Left" Width="140" />
        <HeaderTemplate>
        </HeaderTemplate>
        <ItemTemplate>
            <asp:RadioButtonList ID="rdoApprovals" runat="server" RepeatDirection="Horizontal"
                        CommandName="ApproveDeny">
                        <asp:ListItem Value="1">Approve</asp:ListItem>
                        <asp:ListItem Value="2">Deny</asp:ListItem>
                </asp:RadioButtonList>
            <asp:Button ID="btnTest" runat="server" Text="test" CommandName="test" />
        </ItemTemplate>
    </telerik:GridTemplateColumn>
  2. Eyup
    Admin
    Eyup avatar
    3690 posts

    Posted 24 Jan Link to this post

    Hello Steven,

    You can achieve this requirement using the own event handler of the RadioButtonList:
    <asp:RadioButtonList ... AutoPostBack="true" OnSelectedIndexChanged="RadioButtonList1_SelectedIndexChanged">

    Alternatively, you can use a client-side event handler (onchange for instance) and fire a grid built-in or custom command using the fireCommand method:
    https://docs.telerik.com/devtools/aspnet-ajax/controls/grid/client-side-programming/gridtableview-object/methods/firecommand

    I hope this will prove helpful.

    Regards,
    Eyup
    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.
  3. Steven
    Steven avatar
    9 posts
    Member since:
    Oct 2012

    Posted 24 Jan in reply to Eyup Link to this post

    Thank you Eyup. The only downside to the controls OnSelectedIndexChanged is that we don't have easy access to grid data/embedded controls.  I just switched to buttons, no biggie.
  4. Eyup
    Admin
    Eyup avatar
    3690 posts

    Posted 29 Jan Link to this post

    Hello Steven,

    I'm glad you've managed to find a solution for your specific case. Generally, you can access the container grid item inside the OnSelectedIndexChanged event handler of the combo using the following approach: (sender as RadComboBox).NamingContainer.

    You can check additional samples here for general knowledge:
    https://www.telerik.com/forums/how-to-have-dropdownlist-and-textbox-inside-a-radgrid#A9aPQyI5vE-ENWi8clmy6Q

    Regards,
    Eyup
    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