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

Radcombobox in EditItemTemplate column - Selection out of range

3 Answers 165 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Amirtha S
Top achievements
Rank 1
Amirtha S asked on 12 Feb 2010, 09:29 PM
Hi
I am making use of a Radcombobox inside a Radgrid during Edit mode. I get this problem when I have different values for the
DataValueField and DataTextField. When I make use of the same valeus for both, I don't get the error and the Radcombobox is geting populated.

 

<telerik:RadComboBox ID="CbAircraftModelType" runat="server" Skin="Black"      
                            SelectedValue='<%# Bind("modelTypeName") %>' EmptyMessage=" Select Aircraft Type"                                
                            HighlightTemplatedItems="True" DataTextField="modelTypeName" DataValueField="modelTypeId"    
                            EnableTextSelection="False" DataSourceID="SqlDataSource_AircraftType"      
                            OnClientSelectedIndexChanged="cb_OnClientSelectedIndexChanged" />    
 
I am making use of a SqlDataSource to populate the Radcombobox.

<asp:SqlDataSource ID="SqlDataSource_AircraftType" runat="server"      
                    ConnectionString="<%$ ConnectionStrings:AvengeConnectionString %>"      
                 SelectCommand="select modelTypeName,modelTypeId from Avenge.dbo.AircraftModelType ">     
            </asp:SqlDataSource>    
 

I don't have any code for working with this in the code-behind.

This is the error that I am getting:

Selection out of range     
Parameter name: value      
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.      
    
Exception Details: System.ArgumentOutOfRangeException: Selection out of range     
Parameter name: value     
    
Source Error:      
    
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.       
    
Stack Trace:      
    
    
[ArgumentOutOfRangeException: Selection out of range     
Parameter name: value]     
   Telerik.Web.UI.RadComboBox.PerformDataBinding(IEnumerable dataSource) +172     
   Telerik.Web.UI.RadComboBox.OnDataSourceViewSelectCallback(IEnumerable data) +39     
   System.Web.UI.DataSourceView.Select(DataSourceSelectArguments arguments, DataSourceViewSelectCallback callback) +31     
   Telerik.Web.UI.RadComboBox.OnDataBinding(EventArgs e) +102     
   Telerik.Web.UI.RadComboBox.PerformSelect() +37     
   System.Web.UI.WebControls.BaseDataBoundControl.DataBind() +73     
   System.Web.UI.Control.DataBindChildren() +211     
   System.Web.UI.Control.DataBind(Boolean raiseOnDataBinding) +102     
   System.Web.UI.Control.DataBind() +15     
   System.Web.UI.Control.DataBindChildren() +211     
   System.Web.UI.Control.DataBind(Boolean raiseOnDataBinding) +102     
   System.Web.UI.Control.DataBind() +15     
   System.Web.UI.Control.DataBindChildren() +211     
   System.Web.UI.Control.DataBind(Boolean raiseOnDataBinding) +102     
   System.Web.UI.Control.DataBind() +15     
   System.Web.UI.Control.DataBindChildren() +211     
   System.Web.UI.Control.DataBind(Boolean raiseOnDataBinding) +102     
   System.Web.UI.Control.DataBind() +15     
   System.Web.UI.Control.DataBindChildren() +211     
   System.Web.UI.Control.DataBind(Boolean raiseOnDataBinding) +102     
   System.Web.UI.Control.DataBind() +15     
   System.Web.UI.Control.DataBindChildren() +211     
   System.Web.UI.Control.DataBind(Boolean raiseOnDataBinding) +102     
   System.Web.UI.Control.DataBind() +15     
   System.Web.UI.Control.DataBindChildren() +211     
   System.Web.UI.Control.DataBind(Boolean raiseOnDataBinding) +102     
   System.Web.UI.Control.DataBind() +15     
   System.Web.UI.Control.DataBindChildren() +211     
   System.Web.UI.Control.DataBind(Boolean raiseOnDataBinding) +102     
   System.Web.UI.Control.DataBind() +15     
   System.Web.UI.Control.DataBindChildren() +211     
   System.Web.UI.Control.DataBind(Boolean raiseOnDataBinding) +102     
   System.Web.UI.Control.DataBind() +15     
   Telerik.Web.UI.GridEditFormItem.SetupItem(Boolean dataBind, Object dataItem, GridColumn[] columns, ControlCollection rows) +387     
   Telerik.Web.UI.GridItemBuilder.CreateItems(GridGroupingContext group) +979     
   Telerik.Web.UI.GridTableView.CreateItems(IEnumerator enumerator, GridColumn[] columns, ControlCollection controls) +187     
   Telerik.Web.UI.GridTableView.CreateControlHierarchy(Boolean useDataSource) +1573     
   Telerik.Web.UI.GridTableView.CreateChildControls(IEnumerable dataSource, Boolean useDataSource) +782     
   System.Web.UI.WebControls.CompositeDataBoundControl.PerformDataBinding(IEnumerable data) +57     
   System.Web.UI.WebControls.DataBoundControl.OnDataSourceViewSelectCallback(IEnumerable data) +114     
   System.Web.UI.DataSourceView.Select(DataSourceSelectArguments arguments, DataSourceViewSelectCallback callback) +31     
   System.Web.UI.WebControls.DataBoundControl.PerformSelect() +142     
   Telerik.Web.UI.GridTableView.PerformSelect() +28     
   System.Web.UI.WebControls.BaseDataBoundControl.DataBind() +73     
   Telerik.Web.UI.GridTableView.DataBind() +351     
   Telerik.Web.UI.GridTableView.Rebind() +98     
   Telerik.Web.UI.GridCommandEventArgs.ExecuteCommand(Object source) +395     
   Telerik.Web.UI.RadGrid.OnBubbleEvent(Object source, EventArgs e) +191     
   System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +37     
   Telerik.Web.UI.GridItem.OnBubbleEvent(Object source, EventArgs e) +165     
   System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +37     
   System.Web.UI.WebControls.LinkButton.OnCommand(CommandEventArgs e) +118     
   System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String eventArgument) +135     
   System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10     
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13     
   System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +175     
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565     
    
      
    
Hope someone will be able to help me with this.  
 
Thanks.  

3 Answers, 1 is accepted

Sort by
0
Joshua Holt
Top achievements
Rank 2
answered on 16 Feb 2010, 12:30 AM
Hi Amirtha,
You are setting the SelectedValue to <%# Bind("modelTypeName") %> however you are binding the value column to DataValueField="modelTypeId" so the combo box is looking for modelTypeName, in the ID column which will not exist.  You need to bind the selectedValue to the modelTypeID to make the code you posted work as expected. 

I hope this helps :)

Thanks!
Joshua Holt
0
Julio Paez
Top achievements
Rank 1
answered on 25 Mar 2010, 11:05 PM
Hi Amirtha,

I have a same problem but in insert mode. When I like insert a new record I get the error System.ArgumentOutOfRangeException: Selection out of range.

<

 

radG:GridTemplateColumn DataField="idTblOpciones" DataType="System.Int32" HeaderText="Tipo Intervencion"

 

 

UniqueName="idTblOpciones">

 

 

<EditItemTemplate>

 

 

<radC:RadComboBox ID="idTblOpcionesDwn" runat="server" DataSourceID="SqlDataSourceTiposIntervencion"

 

 

DataTextField="NombreOpcion" DataValueField="idTblOpciones" Skin="Office2007"

 

 

SelectedValue="<%# Bind('idTblOpciones') %>"

 

 

SkinsPath="~/RadControls/ComboBox/Skins" Width="150px">

 

 

</radC:RadComboBox>

 

 

</EditItemTemplate>

 

 

<ItemTemplate>

 

 

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

 

 

</ItemTemplate>

 

 

</radG:GridTemplateColumn>

 


I am using sqlDataSource to populated the radComboBox:

<

 

asp:SqlDataSource ID="SqlDataSourceTiposIntervencion" runat="server" ConnectionString="<%$ ConnectionStrings:VIGIAConnectionString %>"

 

 

SelectCommand="spGetTblOpcionesbyLista" SelectCommandType="StoredProcedure">

 

 

<SelectParameters>

 

 

<asp:Parameter DefaultValue="240" Name="idTblListas" Type="Int32" />

 

 

</SelectParameters>

 

 

</asp:SqlDataSource>

 


Can you help me to resolved this error?

thanks,

Julio P
0
Simon
Telerik team
answered on 29 Mar 2010, 01:32 PM
Hello Julio Paez,

This happens because there is no value in the idTblOpciones column in the DataItem of the Grid Item in Insert Mode (you are about to choose that data on insertion). The RadComboBox tries to select the empty string and it fails because probably all Items have values.

You can either add a default Item (Value="") inline and set the AppendDataBoundItems to true on the RCB, add the same Item directly in the data source or remove the Bind expression and manually supply the selected value of the RCB in the Inserting event of the data source.

An example of the first approach:
<telerik:RadComboBox ID="RadComboBox1" runat="server" AppendDataBoundItems="true" ...>
    <Items>
        <telerik:RadComboBoxItem Text="Choose a Value" Value="" />
    </Items>
</telerik:RadComboBox>

Sincerely yours,
Simon
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
ComboBox
Asked by
Amirtha S
Top achievements
Rank 1
Answers by
Joshua Holt
Top achievements
Rank 2
Julio Paez
Top achievements
Rank 1
Simon
Telerik team
Share this question
or