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

[Solved] Hide radtextbox with checkbox inside EditFormTemplate of radgrid

3 Answers 212 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Carina
Top achievements
Rank 1
Carina asked on 03 May 2013, 06:39 PM
Is it possible to have a checkbox inside the editform template of a radgrid that will make a radtextbox visible when checked, and not visible when unchecked? All these controls would be in the EditFormTemplate of the radgrid and should be able to appear it and disappear it while still in EditForm. I am working with VB and I have looked at the examples, but none explain about checkbox, since they are different than radcomboboxes or dropdownlists.

3 Answers, 1 is accepted

Sort by
0
Jayesh Goyani
Top achievements
Rank 2
answered on 04 May 2013, 05:32 PM
Hello,

Please try with below code snippet.

Client side:
function ValidateGrid(obj) {
               var txt = $telerik.findTextBox(obj.id.replace("CheckBox1", "RadTextBox1"));
               txt.set_visible(obj.checked)
           }
<EditFormSettings EditFormType="Template">
                   <FormTemplate>
                       <asp:CheckBox ID="CheckBox1" runat="server" onclick="ValidateGrid(this);" />
                       <telerik:RadTextBox ID="RadTextBox1" runat="server">
                       </telerik:RadTextBox>
                   </FormTemplate>
               </EditFormSettings>

http://jayeshgoyani.blogspot.in/2012/07/access-another-control-which-was-in.html

Server side:
<EditFormSettings EditFormType="Template">
                   <FormTemplate>
                       <asp:CheckBox ID="CheckBox1" runat="server" AutoPostBack="true" OnCheckedChanged="CheckBox1_CheckedChanged" />
                       <telerik:RadTextBox ID="RadTextBox1" runat="server">
                       </telerik:RadTextBox>
                   </FormTemplate>
               </EditFormSettings>
protected void CheckBox1_CheckedChanged(object sender, EventArgs e)
        {
 
            CheckBox CheckBox1 = sender as CheckBox;
            GridEditFormItem item = CheckBox1.NamingContainer as GridEditFormItem;
            RadTextBox RadTextBox1 = item.FindControl("RadTextBox1") as RadTextBox;
            RadTextBox1.Visible = CheckBox1.Checked;
        }


Thanks,
Jayesh Goyani
0
Carina
Top achievements
Rank 1
answered on 06 May 2013, 08:46 PM

Hi,

I am trying to do it on the server side. I cannot do it that way because, I cannot access the check box because it is inside the radgrid. I am working in vb.net. I have tried many function in the Item databound of the radgrid, but nothing seems to work. Any ideas?
0
Shinu
Top achievements
Rank 2
answered on 07 May 2013, 04:31 AM
Hi,

You can attach checkchanged event for the checkbox as shown below.
VB:
Protected Sub CheckBox1_CheckedChanged(sender As Object, e As EventArgs)
Dim CheckBox1 As CheckBox = TryCast(sender, CheckBox)
    Dim item As GridEditFormItem = TryCast(CheckBox1.NamingContainer, GridEditFormItem)
    Dim RadTextBox1 As RadTextBox = TryCast(item.FindControl("RadTextBox1"), RadTextBox)
    RadTextBox1.Visible = CheckBox1.Checked
End Sub

Thanks,
Shinu
Tags
Grid
Asked by
Carina
Top achievements
Rank 1
Answers by
Jayesh Goyani
Top achievements
Rank 2
Carina
Top achievements
Rank 1
Shinu
Top achievements
Rank 2
Share this question
or