Read Value of CommandItemTemplate CheckBox

3 posts, 0 answers
  1. Perry
    Perry avatar
    62 posts
    Member since:
    Jul 2015

    Posted 05 Nov 2015 Link to this post

    I have a RadGrid with the following CommandItemTemplate items

    <asp:Button ID="Diagram" Text="Diagram" runat="server" OnClick="DiagramClicked"></asp:Button>
    <asp:CheckBox ID="OrphanCheck" Text="Exclude Orphans" runat="server"/>

    When the user clicks the Diagram button, using C#  I want to read the value of the Checkbox and build the needed code based on the value of the check box.  How can I get the value of that checkbox.  I have searched for a solution but all I can find is dealing with a checkbox in a column or row.




  2. Konstantin Dikov
    Konstantin Dikov avatar
    2466 posts

    Posted 10 Nov 2015 Link to this post

    Hello Perry,

    To get reference to the CheckBox control you can use the NamingContainer of the Button control and use the FindControl method with the ID of the CheckBox:
    protected void Diagram_Click(object sender, EventArgs e)
        bool checkBoxChecked = ((sender as Button).NamingContainer.FindControl("OrphanCheck") as CheckBox).Checked;

    Hope this helps.

    Konstantin Dikov
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. Perry
    Perry avatar
    62 posts
    Member since:
    Jul 2015

    Posted 10 Nov 2015 in reply to Konstantin Dikov Link to this post

    Yes that was a great help thank you for your time
Back to Top