This question is locked. New answers and comments are not allowed.
Let me start by saying I love the controls and how easy they make everything.
I have an issue with the gird control using Foreign Key columns, When initially loading data and on refreshes it works beautifully but when I try to use the edit command with a pop up window (built in) I get the following error....
The Model I am loading from is an Entity Framework model. In particular the Stories object is a "main" table with quite a few foreign key relationships. Here is the view code.
Please help. I would really rather use the ForeignKeyColumn type then creating a custom model and modifying things that way....
I have an issue with the gird control using Foreign Key columns, When initially loading data and on refreshes it works beautifully but when I try to use the edit command with a pop up window (built in) I get the following error....
Server Error in '/' Application.An item with the same key has already been added.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.ArgumentException: An item with the same key has already been added.Source Error: Line 6: <h2>Line 7: USer Stories</h2>Line 8: @(Line 9: Html.Telerik().Grid(Model).Name("ContactGrid").DataKeys(datakey => datakey.Add(c => c.StoryId).RouteKey("StoryId"))Line 10: .DataBinding(databinding =>Source File: c:\Users\cmcnear\Documents\Visual Studio 2010\Projects\MWest\MWestRazor\Views\Admin\UserStories.cshtml Line: 8 Stack Trace: [ArgumentException: An item with the same key has already been added.] System.ThrowHelper.ThrowArgumentException(ExceptionResource resource) +52 System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add) +9374523 System.Web.Mvc.ViewDataDictionary.Add(String key, Object value) +15 Telerik.Web.Mvc.UI.GridForeignKeyColumn`2.AppendSelectList(IDictionary`2 viewData, Object dataItem) in f:\115\Griffin\Trunk Full\Sources\Source\Telerik.Web.Mvc\UI\Grid\Columns\GridForeignKeyColumn.cs:95 Telerik.Web.Mvc.UI.Html.<>c__DisplayClass2.<EditorForModel>b__0(Action`2 action) in f:\115\Griffin\Trunk Full\Sources\Source\Telerik.Web.Mvc\UI\Grid\Html\GridHtmlHelper.cs:61 Telerik.Web.Mvc.Extensions.EnumerableExtensions.Each(IEnumerable`1 instance, Action`1 action) in f:\115\Griffin\Trunk Full\Sources\Source\Telerik.Web.Mvc\Extensions\EnumerableExtensions.cs:61 Telerik.Web.Mvc.UI.Html.GridHtmlHelper`1.EditorForModel(Object dataItem, String templateName, IEnumerable`1 foreignKeyData, Object additionalViewData) in f:\115\Griffin\Trunk Full\Sources\Source\Telerik.Web.Mvc\UI\Grid\Html\GridHtmlHelper.cs:61 Telerik.Web.Mvc.UI.Html.<>c__DisplayClass29.<CreateEditFormBuilder>b__26() in f:\115\Griffin\Trunk Full\Sources\Source\Telerik.Web.Mvc\UI\Grid\Html\GridRowBuilderFactory.cs:270 Telerik.Web.Mvc.UI.Html.GridEditFormBuilder.AppendEditor(IHtmlNode form) in f:\115\Griffin\Trunk Full\Sources\Source\Telerik.Web.Mvc\UI\Grid\Html\GridEditFormBuilder.cs:51 Telerik.Web.Mvc.UI.Html.GridEditFormBuilder.CreateForm() in f:\115\Griffin\Trunk Full\Sources\Source\Telerik.Web.Mvc\UI\Grid\Html\GridEditFormBuilder.cs:31 Telerik.Web.Mvc.UI.Html.GridPopUpEditRowBuilder.CreateRow() in f:\115\Griffin\Trunk Full\Sources\Source\Telerik.Web.Mvc\UI\Grid\Html\GridPopUpEditRowBuilder.cs:25 Telerik.Web.Mvc.UI.Html.GridRowBuilderDecoratorBase.CreateRow() in f:\115\Griffin\Trunk Full\Sources\Source\Telerik.Web.Mvc\UI\Grid\Html\GridRowBuilderDecoratorBase.cs:39 Telerik.Web.Mvc.UI.Html.GridRowBuilderDecoratorBase.CreateRow() in f:\115\Griffin\Trunk Full\Sources\Source\Telerik.Web.Mvc\UI\Grid\Html\GridRowBuilderDecoratorBase.cs:39 Telerik.Web.Mvc.UI.Html.GridRowBuilderDecoratorBase.CreateRow() in f:\115\Griffin\Trunk Full\Sources\Source\Telerik.Web.Mvc\UI\Grid\Html\GridRowBuilderDecoratorBase.cs:39 Telerik.Web.Mvc.UI.Html.GridRowBuilderDecoratorBase.CreateRow() in f:\115\Griffin\Trunk Full\Sources\Source\Telerik.Web.Mvc\UI\Grid\Html\GridRowBuilderDecoratorBase.cs:39 Telerik.Web.Mvc.UI.Html.GridRowBuilderDecoratorBase.CreateRow() in f:\115\Griffin\Trunk Full\Sources\Source\Telerik.Web.Mvc\UI\Grid\Html\GridRowBuilderDecoratorBase.cs:39 Telerik.Web.Mvc.UI.Html.GridRowBuilderDecoratorBase.CreateRow() in f:\115\Griffin\Trunk Full\Sources\Source\Telerik.Web.Mvc\UI\Grid\Html\GridRowBuilderDecoratorBase.cs:39 Telerik.Web.Mvc.UI.Html.GridRowBuilderDecoratorBase.CreateRow() in f:\115\Griffin\Trunk Full\Sources\Source\Telerik.Web.Mvc\UI\Grid\Html\GridRowBuilderDecoratorBase.cs:39 Telerik.Web.Mvc.UI.Html.GridDataSectionBuilder.CreateBody(IEnumerable`1 rowBuilders) in f:\115\Griffin\Trunk Full\Sources\Source\Telerik.Web.Mvc\UI\Grid\Html\GridDataSectionBuilder.cs:38 Telerik.Web.Mvc.UI.Html.GridDataSectionBuilder.CreateBody(GridRenderingData renderingData) in f:\115\Griffin\Trunk Full\Sources\Source\Telerik.Web.Mvc\UI\Grid\Html\GridDataSectionBuilder.cs:29 Telerik.Web.Mvc.UI.Html.GridHtmlBuilder.CreateBody(GridRenderingData renderingData) in f:\115\Griffin\Trunk Full\Sources\Source\Telerik.Web.Mvc\UI\Grid\Html\GridHtmlBuilder.cs:193 Telerik.Web.Mvc.UI.Html.GridHtmlBuilder.AppendData(IHtmlNode div, GridRenderingData renderingData) in f:\115\Griffin\Trunk Full\Sources\Source\Telerik.Web.Mvc\UI\Grid\Html\GridHtmlBuilder.cs:68 Telerik.Web.Mvc.UI.Html.GridHtmlBuilder.CreateGrid(IDictionary`2 htmlAttributes, GridFunctionalData functionalData, GridRenderingData renderingData) in f:\115\Griffin\Trunk Full\Sources\Source\Telerik.Web.Mvc\UI\Grid\Html\GridHtmlBuilder.cs:43 Telerik.Web.Mvc.UI.Grid`1.WriteHtml(HtmlTextWriter writer) in f:\115\Griffin\Trunk Full\Sources\Source\Telerik.Web.Mvc\UI\Grid\Grid.cs:676 Telerik.Web.Mvc.UI.ViewComponentBase.ToHtmlString() in f:\115\Griffin\Trunk Full\Sources\Source\Telerik.Web.Mvc\UI\ViewComponentBase.cs:215 Telerik.Web.Mvc.UI.ViewComponentBuilderBase`2.ToHtmlString() in f:\115\Griffin\Trunk Full\Sources\Source\Telerik.Web.Mvc\UI\ViewComponentBuilderBase.cs:154 Telerik.Web.Mvc.{Dynamic}.GridBuilder`1[[MWestRazor.Models.UserStory, MWestRazor, Version=1.0.0.0\, Culture=neutral\, PublicKeyToken=null\]\].IHtmlString.ToHtmlString() +31 System.Web.HttpUtility.HtmlEncode(Object value) +38 System.Web.WebPages.WebPageBase.Write(Object value) +64 ASP._Page_Views_Admin_UserStories_cshtml.Execute() in c:\Users\cmcnear\Documents\Visual Studio 2010\Projects\MWest\MWestRazor\Views\Admin\UserStories.cshtml:8 System.Web.WebPages.WebPageBase.ExecutePageHierarchy() +207 System.Web.Mvc.WebViewPage.ExecutePageHierarchy() +81 System.Web.WebPages.StartPage.RunPage() +19 System.Web.WebPages.StartPage.ExecutePageHierarchy() +65 System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +76 System.Web.Mvc.RazorView.RenderView(ViewContext viewContext, TextWriter writer, Object instance) +220 System.Web.Mvc.BuildManagerCompiledView.Render(ViewContext viewContext, TextWriter writer) +115 System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context) +303 System.Web.Mvc.ControllerActionInvoker.InvokeActionResult(ControllerContext controllerContext, ActionResult actionResult) +13 System.Web.Mvc.<>c__DisplayClass1c.<InvokeActionResultWithFilters>b__19() +23 System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation) +260 System.Web.Mvc.<>c__DisplayClass1e.<InvokeActionResultWithFilters>b__1b() +19 System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList`1 filters, ActionResult actionResult) +177 System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +343 System.Web.Mvc.Controller.ExecuteCore() +116 System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) +97 System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(RequestContext requestContext) +10 System.Web.Mvc.<>c__DisplayClassb.<BeginProcessRequest>b__5() +37 System.Web.Mvc.Async.<>c__DisplayClass1.<MakeVoidDelegate>b__0() +21 System.Web.Mvc.Async.<>c__DisplayClass8`1.<BeginSynchronous>b__7(IAsyncResult _) +12 System.Web.Mvc.Async.WrappedAsyncResult`1.End() +62 System.Web.Mvc.<>c__DisplayClasse.<EndProcessRequest>b__d() +50 System.Web.Mvc.SecurityUtil.<GetCallInAppTrustThunk>b__0(Action f) +7 System.Web.Mvc.SecurityUtil.ProcessInApplicationTrust(Action action) +22 System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +60 System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +9 System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +8969117 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +184Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.272The Model I am loading from is an Entity Framework model. In particular the Stories object is a "main" table with quite a few foreign key relationships. Here is the view code.
@using System.Collections@model IEnumerable<MWestRazor.Models.UserStory>@{ ViewBag.Title = "Stories";}<h2> USer Stories</h2>@( Html.Telerik().Grid(Model).Name("ContactGrid").DataKeys(datakey => datakey.Add(c => c.StoryId).RouteKey("StoryId")) .DataBinding(databinding => databinding.Server() .Select("UserStories", "Admin") .Delete("DeleteStory", "Admin") .Update("UpdateStory", "Admin")) .Columns(columns => { columns.ForeignKey(story => story.UserId, (IEnumerable)ViewData["AllUsers"], "UserId", "FirstName").Title("First Name").ReadOnly(true); columns.ForeignKey(story => story.UserId, (IEnumerable)ViewData["AllUsers"], "UserId", "LastName").Title("Last Name").ReadOnly(true); columns.ForeignKey(story => story.UserId, (IEnumerable)ViewData["AllUsers"], "UserId", "Email").Title("Email Address").ReadOnly(true); columns.ForeignKey(story => story.UserId, (IEnumerable)ViewData["AllUsers"], "UserId", "PoatalCode").Title("Postal Code").ReadOnly(true); columns.Bound(column => column.Story).Title("Story").ReadOnly(true); columns.ForeignKey(story => story.Contact, (IEnumerable)ViewData["ContactOptions"], "ContactID", "ContactDescription").Title("Contact"); columns.ForeignKey(story => story.Status, (IEnumerable)ViewData["StatusOptions"], "StatusId", "StatusDescription").Title("Status"); columns.ForeignKey(story => story.Category, (IEnumerable)ViewData["CategoryOptions"], "CategoryId", "CategoryDescription").Title("Category"); columns.Command(commands => { commands.Edit().ButtonType(GridButtonType.Image); commands.Delete().ButtonType(GridButtonType.Image); }).Title("Editing"); }) .Editable(editing => editing.Mode(GridEditMode.PopUp)) .Sortable() .Pageable() )Please help. I would really rather use the ForeignKeyColumn type then creating a custom model and modifying things that way....