I am binding grid in Razor View with an IQuerable data source of type "DataRow". I am getting the below specified error.
The Controller Code is :
<HttpPost()> Function SearchResults(criteria As Infinity.ContactMgmt.Objects.ContactSearchCriteria) As ActionResult Dim contactsearchResults = Infinity.ContactMgmt.Objects.ContactSearch.Fetch(criteria) ViewData("SearchResults") = contactsearchResults.ContactSearchResults.AsQueryable Return View() End Function
View is:
@(Html.Infragistics().Grid(Of Infinity.ContactMgmt.Objects.ContactSearchData.ContactSearchResultsRow)(Model) _ .ID("grid1") _ .AutoGenerateColumns(False) _ .Columns(Function(columns) columns.For(Function(c) c.ContactId).HeaderText("User Id").DataType("Int") columns.For(Function(c) c.FileAsName).HeaderText("Name").DataType("String") End Function) _ .Width("100%") _ .Height("350") _ .DataBind() _ .Render())
There are more than 20 columns in Model but we only want to display two columns.
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.Reflection.TargetParameterCountException: Parameter count mismatch.Source Error:
Line 5: <legend>Contact Search Results</legend> Line 6: <p> Line 7: @(Html.Infragistics().Grid(Of Infinity.ContactMgmt.Objects.ContactSearchData.ContactSearchResultsRow)(Model) _ Line 8: .ID("grid1") _ Line 9: .AutoGenerateColumns(False) _
Source File: D:\Test\MvcApplication1\MvcApplication1\Views\ContactSearch\ViewUserControlContactSearchResults.vbhtml Line: 7 Stack Trace:
[TargetParameterCountException: Parameter count mismatch.] System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks) +10280741 System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) +21 System.Reflection.RuntimePropertyInfo.GetValue(Object obj, BindingFlags invokeAttr, Binder binder, Object[] index, CultureInfo culture) +61 System.Reflection.RuntimePropertyInfo.GetValue(Object obj, Object[] index) +19 Infragistics.Web.Mvc.GridModel.RenderHierarchicalQueryableRecursive(IQueryable queryable, WrappedGridResponse response, GridModel baseLayout) +556 Infragistics.Web.Mvc.GridModel.RenderHierarchicalQueryableRecursive(IQueryable queryable, WrappedGridResponse response, GridModel baseLayout) +2060 Infragistics.Web.Mvc.GridModel.RenderHierarchicalQueryable(IQueryable queryable) +359 Infragistics.Web.Mvc.GridModel.DataBind() +355 Infragistics.Web.Mvc.Grid`1.DataBind() +47 ASP._Page_Views_ContactSearch_ViewUserControlContactSearchResults_vbhtml.Execute() in D:\Test\MvcApplication1\MvcApplication1\Views\ContactSearch\ViewUserControlContactSearchResults.vbhtml:7 System.Web.WebPages.WebPageBase.ExecutePageHierarchy() +197 System.Web.Mvc.WebViewPage.ExecutePageHierarchy() +81 System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +88 System.Web.Mvc.RazorView.RenderView(ViewContext viewContext, TextWriter writer, Object instance) +222 System.Web.Mvc.BuildManagerCompiledView.Render(ViewContext viewContext, TextWriter writer) +115 System.Web.Mvc.HtmlHelper.RenderPartialInternal(String partialViewName, ViewDataDictionary viewData, Object model, TextWriter writer, ViewEngineCollection viewEngineCollection) +276 System.Web.Mvc.Html.PartialExtensions.Partial(HtmlHelper htmlHelper, String partialViewName, Object model, ViewDataDictionary viewData) +108 System.Web.Mvc.Html.PartialExtensions.Partial(HtmlHelper htmlHelper, String partialViewName, Object model) +32 ASP._Page_Views_ContactSearch_SearchResults_vbhtml.Execute() in D:\Test\MvcApplication1\MvcApplication1\Views\ContactSearch\SearchResults.vbhtml:11 System.Web.WebPages.WebPageBase.ExecutePageHierarchy() +197 System.Web.Mvc.WebViewPage.ExecutePageHierarchy() +81 System.Web.WebPages.StartPage.RunPage() +17 System.Web.WebPages.StartPage.ExecutePageHierarchy() +62 System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +76 System.Web.Mvc.RazorView.RenderView(ViewContext viewContext, TextWriter writer, Object instance) +222 System.Web.Mvc.BuildManagerCompiledView.Render(ViewContext viewContext, TextWriter writer) +115 System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context) +295 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) +242 System.Web.Mvc.<>c__DisplayClass1e.<InvokeActionResultWithFilters>b__1b() +21 System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList`1 filters, ActionResult actionResult) +177 System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +324 System.Web.Mvc.Controller.ExecuteCore() +106 System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) +91 System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(RequestContext requestContext) +10 System.Web.Mvc.<>c__DisplayClassb.<BeginProcessRequest>b__5() +34 System.Web.Mvc.Async.<>c__DisplayClass1.<MakeVoidDelegate>b__0() +19 System.Web.Mvc.Async.<>c__DisplayClass8`1.<BeginSynchronous>b__7(IAsyncResult _) +10 System.Web.Mvc.Async.WrappedAsyncResult`1.End() +62 System.Web.Mvc.<>c__DisplayClasse.<EndProcessRequest>b__d() +48 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() +9478661 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +178
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.17379
Hello Pardeep,
The error appears in generation of the hierarchical column layouts of the grid model. I see that you didn't explicitly configured column layouts, so probably you don't want hierarchical grid. Try to add the following code to your grid configuration in order to disable automatic column layout generation:
.AutoGenerateLayouts(False) _
Also in the controller you're saving the data in the ViewData, but in the View you use the Model variable to pass the data to the grid. You should change your controller code code to pass the data to the view.Here is an example code:
<HttpPost()>Function SearchResults(criteria As Infinity.ContactMgmt.Objects.ContactSearchCriteria) As ActionResultDim contactsearchResults = Infinity.ContactMgmt.Objects.ContactSearch.Fetch(criteria)Return View(contactsearchResults.ContactSearchResults.AsQueryable)End Function
Hope this helps,
Martin PavlovInfragistics, Inc.
I could provide a sample, but it isn't any different from other examples that work (other than the underlying data, which has many dependencies so I can't easily provide that). Also, the same exact code works on some systems.
The only parameter being passed is the IQueryable.
I guess I was hoping this had been seen and addressed elsewhere, so some direction to hunt in would be available. Apparently it is rare enough that that isn't the case. Thanks.
Hey there Jason,I'm afraid that unless you or the original poster provide some more details or a sample where the problem can be reproduced, we can't provide you with any further assistance.The best (and wild) guess I could wager is that the igGrid's MVC constructor is receiving more than one parameter for some reason when it should expect only one - the IQueryabl that it's data-bound to.If you are able to provide such a sample, please post it here or in a new support request so we can take a closer look at the problem and then - provide you with a slick solution :).Thanks in advance!
I'm experiencing this same issue, but only on one client's machine. Works fine on my dev machine and other client machines with the same code and same IIS setup (As far as I can tell). Would be very interested in any fixes or other information available.
Hi,I haven't seen this error before so I'm afraid that I would have to ask you to provide us with a simple MVC sample project where the problem is reproducible.Feel free to set up just one or two rows of dummy data - me and the other forum members will need to inspect the way the grid is configured in the sample (sorry - the grid's code alone is insufficient in this case).
Looking forward to your reply.Cheers,Borislav