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

No InsertItemTemplate in RadGrid?

1 Answer 180 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:14 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.

 

 

<telerik:GridTemplateColumn HeaderText="Status" SortExpression="Status">

 

 

 

<EditItemTemplate>

 

 

 

<telerik:RadComboBox ID="StatusRadComboBox" runat="server" SelectedValue='<%# Bind("Status") %>'>

 

 

 

<Items>

 

 

 

<telerik:RadComboBoxItem Text="" Value=""></telerik:RadComboBoxItem>

 

 

 

<telerik:RadComboBoxItem Text="Assigned" Value="Assigned"></telerik:RadComboBoxItem>

 

 

 

<telerik:RadComboBoxItem Text="Lost" Value="Lost"></telerik:RadComboBoxItem>

 

 

 

<telerik:RadComboBoxItem Text="Returned" Value="Returned"></telerik:RadComboBoxItem>

 

 

 

</Items>

 

 

 

</telerik:RadComboBox>

 

 

 

<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="Value is required"

 

 

 

ControlToValidate="StatusRadComboBox"></asp:RequiredFieldValidator>

 

 

 

</EditItemTemplate>

 

 

 

<ItemTemplate>

 

 

 

<asp:Label ID="Label1" runat="server" Text='<%# Bind("Status") %>'></asp:Label>

 

 

 

</ItemTemplate>

 

 

 

</telerik:GridTemplateColumn>

 




Jon

1 Answer, 1 is accepted

Sort by
0
Marin
Telerik team
answered on 23 Sep 2010, 11:40 AM
Hello Jon,

The event you are looking for is the ItemCreated. You can handle there the different cases for inserting and editing items in RadGrid and set properties of the form controls. Please have a look at the following article for further details and an example on how to use the preceding event for your purposes. 

All the best,
Marin
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Grid
Asked by
Jon
Top achievements
Rank 1
Answers by
Marin
Telerik team
Share this question
or