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

Read Value of CommandItemTemplate CheckBox

2 Answers 102 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Perry
Top achievements
Rank 1
Perry asked on 05 Nov 2015, 05:49 PM

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.

 

Thanks

Perry

2 Answers, 1 is accepted

Sort by
0
Konstantin Dikov
Telerik team
answered on 10 Nov 2015, 10:10 AM
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.


Regards,
Konstantin Dikov
Telerik
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
0
Perry
Top achievements
Rank 1
answered on 10 Nov 2015, 12:47 PM
Yes that was a great help thank you for your time
Tags
Grid
Asked by
Perry
Top achievements
Rank 1
Answers by
Konstantin Dikov
Telerik team
Perry
Top achievements
Rank 1
Share this question
or