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

[Solved] RadComboBox with LoadOnDemand in Grid

3 Answers 164 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
TPerry
Top achievements
Rank 1
TPerry asked on 19 Aug 2009, 01:51 PM
I have a RadGrid and one of my columns is Resource, which is a GridTemplateColumn which holds a RadComboBox utilizing LoadOnDemand.  I can get it to partially work.  If I insert a new record, the LoadOnDemand works fine and it saves the value of the ComboBox in my DB.  However, if I then Edit that line, I always get 'Selection out of Range.'  I'm guessing that this is because the ComboBox has no values in it yet.  So, in my ItemDataBound event, I add a new ComboBoxItem containing the Text and Values of the selected Resource.  My problem is that I get the error before it hits this event.  What am I missing?

Here's my ComboBox code:

<

 

telerik:GridTemplateColumn UniqueName="Resource" HeaderText="Resource" DataField="Name">

 

 

<ItemTemplate>

 

 

<asp:Label ID="lblResourceName" runat="server" Text='<%# Eval("ResourceName")%>' ></asp:Label>

 

 

</ItemTemplate>

 

 

<EditItemTemplate>

 

 

<telerik:RadComboBox ID="Resource" AllowCustomText="true" runat="server" Text='<%# Bind("Resource") %>'

 

 

Height="100px" EmptyMessage="Search..." SelectedValue='<%# Bind("Resource") %>'

 

 

EnableVirtualScrolling="true" DataTextField="Name" DataValueField="Resource"

 

 

EnableLoadOnDemand="true" OnItemsRequested="Resource_ItemsRequested" AppendDataBoundItems="true"

 

 

>

 

 

</telerik:RadComboBox>

 

 

</EditItemTemplate>

 

 

 

</telerik:GridTemplateColumn>

And here's my ItemDataBound event:

 

If

 

(TypeOf e.Item Is GridEditableItem AndAlso e.Item.IsInEditMode) Then

 

 

'Populates the Resource DDL with the selected Resource

 

 

 

 

 

Dim ResourceDDL As RadComboBox = CType(GridItem("Resource").FindControl("Resource"), RadComboBox)

 

 

Dim objBNF As New PBBRL.EntityClass.xBudgetNodeFees

 

objBNF.FetchUsingPK(BudgetNodeFeesID)

 

Dim ResourceID As String = objBNF.Resource

 

 

Dim ResourceItem As New RadComboBoxItem

 

ResourceItem.Text = ResourceID

ResourceItem.Value = ResourceID

ResourceItem.Selected =

True

 

 

 

 

ResourceDDL.Items.Add(ResourceItem)
End If

3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 20 Aug 2009, 08:12 AM
Hi,

Try populating the Combobox in the ItemRequested event of the RadCombox and see whether it is working. You can also refer the following online demo which demonstrates a RadComboBox nested inside a GridTemplateColumn.
Combo in Grid

Thanks
Princy
0
Accepted
Veselin Vasilev
Telerik team
answered on 20 Aug 2009, 12:13 PM
Hi,

Please find attached a sample project. You need to use a slightly different technique to achieve that,

I hope this helps.

Regards,
Veselin Vasilev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
TPerry
Top achievements
Rank 1
answered on 20 Aug 2009, 03:20 PM
Thank you!  Thank you!
Tags
ComboBox
Asked by
TPerry
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Veselin Vasilev
Telerik team
TPerry
Top achievements
Rank 1
Share this question
or