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

Checkedit form template

1 Answer 25 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Joslyn
Top achievements
Rank 1
Joslyn asked on 23 Dec 2013, 02:10 PM
Hi,
In edit form template i have a checkbox and on its selection i want to visible a textbox.

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 23 Dec 2013, 02:39 PM
Hi Josyln,

Please try the following code snippet :

ASPX:
<EditFormSettings EditFormType="Template">
            <FormTemplate>
                <table>
                    <tr>
                        <td>
                            Check:
                        </td>
                        <td>
                            <asp:CheckBox ID="CheckBox1" runat="server" AutoPostBack="true" OnCheckedChanged="CheckBox1_CheckedChanged" />
                        </td>
                    </tr>
                    <tr>
                        <td>
                            ShipCity:
                        </td>
                        <td>
                            <telerik:RadTextBox ID="txt_ShipCity" runat="server" Text='<%#Bind("ShipCity")%>'
                                Visible="false">
                            </telerik:RadTextBox>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <asp:Button ID="btnUpdate" Text='<%# (Container is GridEditFormInsertItem) ? "Insert" : "Update" %>'
                                runat="server" CommandName='<%# (Container is GridEditFormInsertItem) ? "PerformInsert" : "Update" %>'>
                            </asp:Button
                            <asp:Button ID="btnCancel" Text="Cancel" runat="server" CausesValidation="False"
                                CommandName="Cancel"></asp:Button>
                        </td>
                    </tr>
                </table>
            </FormTemplate>
        </EditFormSettings>

C#:
protected void CheckBox1_CheckedChanged(object sender, EventArgs e)
{
    CheckBox check = (CheckBox)sender;
    GridEditableItem edit = (GridEditableItem)check.NamingContainer;
    RadTextBox txt = (RadTextBox)edit.FindControl("txt_ShipCity");
    if (check.Checked)
    {
        txt.Visible = true;
    }
    else
    {
        txt.Visible = false;
    }
}

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