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

[Solved] An item with the same key has already been added.

1 Answer 180 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Rob Heckart
Top achievements
Rank 1
Rob Heckart asked on 09 Oct 2009, 11:10 PM
Hi,

I have a project that uses the radCombobox (v2009.2.826.35). I am declaring two LinqDataSources on the form and binding the comboboxes to those sources. On occassion I am receiving this error in the Application_Error event in Global.asax via logging:

System.Web.HttpUnhandledException: Exception of type 'System.Web.HttpUnhandledException' was thrown. ---> System.ArgumentException: An item with the same key has already been added.  
  at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)  
  at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)  
  at System.Web.Query.Dynamic.ClassFactory.GetDynamicClass(IEnumerable`1 properties)  
  at System.Web.Query.Dynamic.ExpressionParser.ParseNew()  
  at System.Web.Query.Dynamic.ExpressionParser.ParseIdentifier()  
  at System.Web.Query.Dynamic.ExpressionParser.ParsePrimaryStart()  
  at System.Web.Query.Dynamic.ExpressionParser.ParsePrimary()  
  at System.Web.Query.Dynamic.ExpressionParser.ParseUnary()  
  at System.Web.Query.Dynamic.ExpressionParser.ParseMultiplicative()  
  at System.Web.Query.Dynamic.ExpressionParser.ParseAdditive()  
  at System.Web.Query.Dynamic.ExpressionParser.ParseComparison()  
  at System.Web.Query.Dynamic.ExpressionParser.ParseLogicalAnd()  
  at System.Web.Query.Dynamic.ExpressionParser.ParseLogicalOr()  
  at System.Web.Query.Dynamic.ExpressionParser.ParseExpression()  
  at System.Web.Query.Dynamic.ExpressionParser.Parse(Type resultType)  
  at System.Web.Query.Dynamic.DynamicExpression.ParseLambda(ParameterExpression[] parameters, Type resultType, String expression, Object[] values)  
  at System.Web.Query.Dynamic.DynamicExpression.ParseLambda(Type itType, Type resultType, String expression, Object[] values)  
  at System.Web.Query.Dynamic.DynamicQueryable.Select(IQueryable source, String selector, Object[] values)  
  at System.Web.UI.WebControls.DynamicQueryableWrapper.Select(IQueryable source, String selector, Object[] values)  
  at System.Web.UI.WebControls.LinqDataSourceView.ExecuteSelectExpressions(IQueryable source, IDictionary`2 whereValues, IOrderedDictionary orderByOrderedValues, IDictionary`2 groupByValues, IDictionary`2 orderGroupsByValues, IDictionary`2 selectNewValues)  
  at System.Web.UI.WebControls.LinqDataSourceView.ExecuteSelectQuery(LinqDataSourceSelectEventArgs selectEventArgs, Object selectResult, Object table, Boolean storeOriginalValues)  
  at System.Web.UI.WebControls.LinqDataSourceView.ExecuteSelect(DataSourceSelectArguments arguments)  
  at System.Web.UI.DataSourceView.Select(DataSourceSelectArguments arguments, DataSourceViewSelectCallback callback)  
  at Telerik.Web.UI.RadComboBox.OnDataBinding(EventArgs e)  
  at Telerik.Web.UI.RadComboBox.PerformSelect()  
  at System.Web.UI.WebControls.BaseDataBoundControl.DataBind()  
  at System.Web.UI.WebControls.BaseDataBoundControl.EnsureDataBound()  
  at System.Web.UI.WebControls.BaseDataBoundControl.OnPreRender(EventArgs e)  
  at Telerik.Web.UI.RadComboBox.OnPreRender(EventArgs e)  
  at System.Web.UI.Control.PreRenderRecursiveInternal()  
  at System.Web.UI.Control.PreRenderRecursiveInternal()  
  at System.Web.UI.Control.PreRenderRecursiveInternal()  
  at System.Web.UI.Control.PreRenderRecursiveInternal()  
  at System.Web.UI.Control.PreRenderRecursiveInternal()  
  at System.Web.UI.Control.PreRenderRecursiveInternal()  
  at System.Web.UI.Control.PreRenderRecursiveInternal()  
  at System.Web.UI.Control.PreRenderRecursiveInternal()  
  at System.Web.UI.Control.PreRenderRecursiveInternal()  
  at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)  
  --- End of inner exception stack trace ---  
  at System.Web.UI.Page.HandleError(Exception e)  
  at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)  
  at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)  
  at System.Web.UI.Page.ProcessRequest()  
  at System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context)  
  at System.Web.UI.Page.ProcessRequest(HttpContext context)  
  at ASP.default_aspx.ProcessRequest(HttpContext context)  
  at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()  
  at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) 

The combobox is being setup on the form like this:
<telerik:RadComboBox ID="cboMilitaryRank" runat="server" 
EnableLoadOnDemand="True" DataSourceID="dsMilitaryRank" Skin="Office2007" 
DataTextField="LookupValue" DataValueField="LookupValueID" 
ToolTip="Please choose a rank from the list or type in your own custom rank." Width="250px" 
AppendDataBoundItems="True">  
  <Items> 
    <telerik:RadComboBoxItem runat="server" Selected="True" /> 
  </Items> 
</telerik:RadComboBox> 

The LinqDataSource is being setup like this:
<asp:LinqDataSource ID="dsMilitaryRank" runat="server" 
ContextTypeName="ConferenceRegistrationModel.ConferenceRegistrationDataContext" 
OrderBy="LookupValue" TableName="MilitaryRanks">  
</asp:LinqDataSource> 

The SQL view is pretty simple and looks like this:
CREATE VIEW [dbo].[vwMilitaryRank]  
AS 
SELECT     dbo.lkpValues.LookupValueID, dbo.lkpValues.LookupValue  
FROM         dbo.lkpCategories INNER JOIN 
                      dbo.lkpValues ON dbo.lkpCategories.CategoryID = dbo.lkpValues.CategoryID  
WHERE     (dbo.lkpCategories.CategoryName = N'Military Rank'

Is there any reason that this should fire and how do I get this error from stopping? I know it's not in my code-behind because all of my code there is surrounded in Try..Catch block with specific wording for logging.

1 Answer, 1 is accepted

Sort by
0
Veselin Vasilev
Telerik team
answered on 14 Oct 2009, 10:52 AM
Hello Rob Heckart,

Everything looks alright at first sight. Can you please send us a sample project so we can run it locally?

Thanks

Greetings,
Veselin Vasilev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
ComboBox
Asked by
Rob Heckart
Top achievements
Rank 1
Answers by
Veselin Vasilev
Telerik team
Share this question
or