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

[Solved] comboBox LoadOnDemand inside grid

1 Answer 168 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
newbie
Top achievements
Rank 1
newbie asked on 29 Apr 2008, 11:34 PM
I have a comboBox inside the EditItemTemplate for a Grid.
I am using the EnableLoadonDemand="true" for combo.

<

EditItemTemplate>
<telerik:RadComboBox ID="ddlDeviceAW" runat="server" EnableEmbeddedSkins="false" Skin="UTC" ImagesPath="../RadControls/UTC/ComboBox" EnableLoadOnDemand="true" LoadingMessage="Loading Device..." MarkFirstMatch="True" ToolTip="Select a Device" EnableVirtualScrolling="true" Width="150px" AllowCustomText="true" OnItemsRequested="ddlDeviceAW_ItemsRequested"></telerik:RadComboBox>
</EditItemTemplate>

The way I am loading the combo is:

protected

void ddlDeviceAW_ItemsRequested(object sender, RadComboBoxItemsRequestedEventArgs e)
{
RadComboBox ddlDevice = (RadComboBox)sender;
ddlDevice.DataSource = ds;
ddlDevice.DataMember = TableName;
ddlDevice .DataTextField = textFieldName;
ddlDevice .DataValueField = valueFieldName;
ddlDevice .DataBind();
}

It gives me an error at the DataBind() statement saying 
"Selection out of range
Parameter name: Value"

I have some more combos outside of the grid which loads fine with this approach.
Am I doing something wrong here.
The error comes only when I load data for the combo in edit mode. For Insert mode the comboBox behaves correctly.

I also have the GridItemBound event handler where I do this:

protected

void grdActiveWarning_ItemDataBound(object source, Telerik.Web.UI.GridItemEventArgs e)
{
if (e.Item is GridEditableItem && (e.Item as GridEditableItem).IsInEditMode)
{
GridEditableItem editItem = e.Item as GridEditableItem;
RadComboBox ddlDirection = (RadComboBox)(editItem.FindControl("ddlDirectionAW"));

ddlDirection.Text = DataBinder.Eval(e.Item.DataItem, "DirectionValue").ToString();
ddlDirection.SelectedValue =
DataBinder.Eval(e.Item.DataItem, "DirectionValue").ToString();

RadComboBox ddlDevice = (RadComboBox)(editItem.FindControl("ddlDeviceAW"));
ddlDevice.Text = DataBinder.Eval(e.Item.DataItem, "DeviceValue").ToString();
ddlDevice.SelectedValue =
DataBinder.Eval(e.Item.DataItem, "DeviceValue").ToString();
}

}

Is there something I need to set which I am not doing for the grid?

1 Answer, 1 is accepted

Sort by
0
newbie
Top achievements
Rank 1
answered on 30 Apr 2008, 01:34 AM
I figured that out.
I was setting a wrong value for the combobox.SelectedValue in my itemDataBound event.

Its working fine now.
Sorry for the trouble
Tags
ComboBox
Asked by
newbie
Top achievements
Rank 1
Answers by
newbie
Top achievements
Rank 1
Share this question
or