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

Accessing a control in the formtemplate.

1 Answer 71 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Scott
Top achievements
Rank 1
Scott asked on 11 Sep 2008, 07:09 PM
We are using a custom form template to edit a data record displayed in the rad grid. The template displays both when we click the "edit" or "add new record" links on the grid. Our goal is to change the display of one particular column, (ClientAccount below), so that when "editing", the corresponding text box is read only (ideally we'd like it to display as a label) and when "inserting" the textbox displays and is open for edit.

What event/sub for the grid (ItemDataBound, ItemCommand, etc) should the logic be placed to adjust the display and what is the syntax for referencing a control in the form template?

We've looked at the "Form template edit form" example for the radgrid for asp.net AJAX, but we can't find the right syntax to reach the template controls.

The following is a section of the aspx code:

<EditFormSettings EditFormType="Template">
<FormTemplate>
    <table id="Table2" cellspacing="2" cellpadding="1" width="100%" border="0">
        <tr class="EditFormHeader">
            <td colspan="2" style="font-size: small"><b>Account Details</b></td>
        </tr>
        <tr>
            <td valign="top">
                <table id="Table3" width="350" border="0"  class="module">
                <tr>
                    <td>Code:</td>
                    <td>
                        <
asp:TextBox ID="txtClientAccount" runat="server" Text='<%# Bind( "ClientAccount" ) %>'></asp:TextBox>
                    </
td>
                </tr>
                <tr>
                    <td>Description:</td>
                    <td>
                        <
asp:TextBox ID="txtAcctDescription" runat="server" Text='<%# Bind( "Description" ) %>' Width="300px"></asp:TextBox>
                    </
td>
                </tr>
                </table>
            </td>
            <td valign="top">
                <table id="Table1" width="350" border="0" class="module">
                <tr>
                    <td>
                        <table id="Table4" width="350" border="0" class="module">
                        <tr>
                            <td>Status:</td>
                            <td><asp:DropDownList ID="ddlStatus" runat="server" SelectedValue='<%# Bind("AccountStatus") %>' AppendDataBoundItems="True">
                                        <asp:ListItem Text="" Value=""></asp:ListItem>
                                        <asp:ListItem Text="Active" Value="Active"></asp:ListItem>
                                        <asp:ListItem Text="Inactive" Value="Inactive"></asp:ListItem>
                                    </asp:DropDownList>
                            </td>
                        </tr>
                        </table>
                    </td>
                </tr>
                </table>
            </td>
        </tr>
        <tr>
            <td align="right" colspan="2">
            <asp:Button ID="btnCancel" Text="Cancel" runat="server" CausesValidation="False" CommandName="Cancel"></asp:Button>
            </td>
        </tr>
</table>
</FormTemplate>
</EditFormSettings>


1 Answer, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 12 Sep 2008, 05:42 AM
Hello Scott,

Please take a look at following links:
Referencing controls in grid row/edit form
Distinguish edit/insert mode on ItemCreated/ItemDataBound

It is possible to use a similar approach in order to set a read-only property for a specific case:
ReadOnly = '<%# ((bool)DataBinder.Eval(Container, "OwnerTableView.IsItemInserted")) %>' 

Regards,
Daniel
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Grid
Asked by
Scott
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Share this question
or