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

Template columns with radiobutton

1 Answer 65 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Alyssa
Top achievements
Rank 1
Alyssa asked on 19 Dec 2013, 12:50 PM
Hi
I have two template columns one with radiobutton the other with a textbox. I want the textbox to be visible only if the radiobutton is selected. How to get this done?

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 19 Dec 2013, 01:01 PM
Hi Alyssa,

Please try the following code snippet:

ASPX:
<telerik:GridTemplateColumn HeaderText="Radio" UniqueName="Radio">
    <ItemTemplate>
        <asp:RadioButton ID="RadioButton1" runat="server" AutoPostBack="true" OnCheckedChanged="RadioButton1_CheckedChanged" />
    </ItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn>
    <ItemTemplate>
        <asp:TextBox ID="TextBox1" runat="server" Visible="false"></asp:TextBox>
    </ItemTemplate>
</telerik:GridTemplateColumn>

C#:
protected void RadioButton1_CheckedChanged(object sender, EventArgs e)
{
    RadioButton radio = (RadioButton)sender;
    GridDataItem gdd = (GridDataItem)radio.NamingContainer;
    TextBox txt = (TextBox)gdd.FindControl("TextBox1");
    if (radio.Checked)
    {
        txt.Visible = true;
    }
}

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