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

No InsertItemTemplate in RadGrid?

1 Answer 21 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jon
Top achievements
Rank 1
Jon asked on 20 Sep 2010, 04:18 PM
Hello,

I have a RadGrid that I'm attempting to use in form editing on. I'm currently using the following GridTemplateColumn. The problem is that what I really need is an InsertItemTemplate like what asp:DetailsView has. This is because I want the Status field to be editable in a RadComboBox on insert, but, non-editable and displayed in a label on edit. Does anyone know if this is possible in RadGrid? I'm assuming that I'll probably have to handle an event and adjust the visibility of fields based on whether it's in insert or edit mode? The problem is that I don't know what event I should use to do this and I also don't know how to lookup the control. I'm assuming I'll probably have to use FindControl() and maybe use the RowIndex to find the proper row in the grid or something. Any help would be greatly appreciated.

 

 

 

<asp:TemplateField HeaderText="Status" SortExpression="Status">
                    <EditItemTemplate>
                        <asp:DropDownList ID="DropDownList1" runat="server" SelectedValue='<%# Bind("Status") %>'>
                            <asp:ListItem Text="" Value=""></asp:ListItem>
                            <asp:ListItem Text="Assigned" Value="Assigned"></asp:ListItem>
                            <asp:ListItem Text="Lost" Value="Lost"></asp:ListItem>
                            <asp:ListItem Text="Returned" Value="Returned"></asp:ListItem>
                        </asp:DropDownList>
                        <%--<asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("Status") %>'></asp:TextBox>--%>
                    </EditItemTemplate>
                    <InsertItemTemplate>
                        <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("Status") %>'></asp:TextBox>
                    </InsertItemTemplate>
                    <ItemTemplate>
                        <asp:Label ID="Label1" runat="server" Text='<%# Bind("Status") %>'></asp:Label>
                    </ItemTemplate>
                </asp:TemplateField>

Jon

1 Answer, 1 is accepted

Sort by
0
Cori
Top achievements
Rank 2
answered on 20 Sep 2010, 07:01 PM
Hello Jon,

You can try something like this:

<asp:TextBox ID="txtStatus" runat="server" Enabled="<%# (Container is GridEditFormInsertItem) ? true : false">
</
asp:TextBox>

You can refer to this url, which does that with the Update buttons:

http://demos.telerik.com/aspnet-ajax/grid/examples/dataediting/templateformupdate/defaultcs.aspx

I hope that helps.
Tags
Grid
Asked by
Jon
Top achievements
Rank 1
Answers by
Cori
Top achievements
Rank 2
Share this question
or