I am trying to redeploy a solution from about 3 years ago. It uses Ignite for ASP.NET MVC (not core). Works fine locally and during deployment gives the error Index was outside the bounds of the array on binding.
The cshtml page that errors is below, I have verified that the SQL data in the controller does have values, and verified all .js and .css files are available and no errors in the pages that call controller for this view. This is using version 17.1.20171.2029 of igGrid. The error occurs on line 37 below, any help is appreciated:
@using Infragistics.Web.Mvc@using System.Data.Entity.Core.Objects@using System.Data;@using MeditechLegacyMVC.Models;@model DataTable@{ Layout = "~/Views/Shared/_LayoutPatient.cshtml"; ViewBag.Title = "Patient Visit Scanned Documents"; TempData.Keep(); string accountNumber = TempData["AccountNumber"].ToString();}
<!-- Ignite UI Required Combined CSS Files --><link href="@Url.Content("~/igniteui/css/themes/infragistics/infragistics.theme.css")" rel="stylesheet" /><link href="@Url.Content("~/igniteui/css/structure/infragistics.css")" rel="stylesheet" />
<script src="@Url.Content("~/js/modernizr.min.js")"></script><script src="@Url.Content("~/js/jquery.min.js")"></script><script src="@Url.Content("~/js/jquery-ui.min.js")"></script>
<!-- Ignite UI Required Combined JavaScript Files --><script src="@Url.Content("~/igniteui/js/infragistics.core.js")"></script><script src="@Url.Content("~/igniteui/js/infragistics.lob.js")"></script><h2>Scanned Documents</h2><br />@using (Html.BeginForm("DocumentListPrint", "Patient", FormMethod.Post)){ <div class="input-group"> <div class="input-group"> <p>Select documents with check box then use print button below to print them</p> <br /> <button id="print" type="submit" class="btn btn-primary btn-default">Print</button> </div> </div> <div class="row"> <br /> @(Html.Infragistics().Grid<ScaPatientDocument> <------- Error line (Model) .PrimaryKey("DocumentNumber") .ID("documentsGrid") .Width("100%") .AutoGenerateColumns(false) .DataSource(Model) .Features(feature => { feature.Responsive() .EnableVerticalRendering(false) .ReactOnContainerWidthChanges(true); feature.Sorting().Type(OpType.Local).Mode(SortingMode.Multiple); feature.Paging().Type(OpType.Local); feature.Filtering().Type(OpType.Local); feature.Selection().MultipleSelection(true); feature.RowSelectors() .EnableCheckBoxes(true) .EnableSelectAllForPaging(true); }) .Columns(column => { //Need to add checkbox for printing
column.For(x => x.DocumentNumber).HeaderText("DocumentNumber").Hidden(true); column.For(x => x.AccountNumber).HeaderText("AccountNumber").Hidden(true); column.For(x => x.Category).HeaderText("Category").Width("20%"); column.For(x => x.DocumentName).HeaderText("Document Name").Width("50%") .Template("<a href=\"../Patient/Document?accountNumber=${AccountNumber}&documentNumber=${DocumentNumber}&pageNumber=1\" target=\"_blank\">${DocumentName}</a>"); column.For(x => x.Date).HeaderText("Document Date").Width("20%"); column.For(x => x.PageCount).HeaderText("Page Count").Width("12%"); }) //.DataSourceUrl(Url.Action("VisitList")) .DataBind() .Render() ) </div> <input id="accountNumber" name="accountNumber" hidden value="@accountNumber" /> @(Html.Hidden("selectedRowsPKs")) <script> $(function () { $("#print").click(function () { var rows = $('#documentsGrid').igGridSelection('selectedRows'); var ids = [rows.length];
for (var i = 0; i < rows.length; i++) { ids[i] = rows[i].id; }
$("#selectedRowsPKs").val(ids); }); }); </script>}
Hello Thomas,
Thank you for using Infragistics forums!
Unfortunately, as per our support policy and product lifecycle I need to inform you that 17.1 is no longer supported. You could try to update to the latest SR for 17.1 - 20171.2082 and see if the problem is solved.
If you update your project to a version still in support but that doesn't solve the issue, please let me know so I can look into it further.
Best regards,
Stamen Stoychev
Stamen:
Thanks for the reply. I guess I was looking for some things to try that may cause this type of thing before having to upgrade. It works locally and worked for this client before as well. This is a new box so I'm thinking potentially a .NET framework mis-match (which I've checked) and that seems fine as well. I have added the stack trace as well, so maybe there is something you all are aware of based on where it in the infragistics codes it's crashing? If not I will try the upgrade route you suggest.
[IndexOutOfRangeException: Index was outside the bounds of the array.]
Infragistics.Web.Mvc.GridModel.PreprocessDataSource(String searchKey, Object searchVal) +3208
Infragistics.Web.Mvc.GridModel.DataBind() +37
Infragistics.Web.Mvc.BaseGridWrapper`2.DataBind() +26
ASP._Page_Views_Patient_DocumentsList_cshtml.Execute() in C:\MeditechArchive\Views\Patient\DocumentsList.cshtml:37
System.Web.WebPages.WebPageBase.ExecutePageHierarchy() +252
System.Web.Mvc.WebViewPage.ExecutePageHierarchy() +148
System.Web.WebPages.StartPage.ExecutePageHierarchy() +86
System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +107
System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context) +375
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +88
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +775
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList`1 filters, ActionResult actionResult) +81
System.Web.Mvc.Async.<>c__DisplayClass3_1.<BeginInvokeAction>b__1(IAsyncResult asyncResult) +188
System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult) +59
System.Web.Mvc.<>c.<BeginExecuteCore>b__152_1(IAsyncResult asyncResult, ExecuteCoreState innerState) +26
System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +73
System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +73
System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +39
System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) +59
System.Web.Mvc.<>c.<BeginProcessRequest>b__20_1(IAsyncResult asyncResult, ProcessRequestState innerState) +40
System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +59
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +602
System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step) +195
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +128
Could there be some sort of connection to database or policy related issue and not being able to access it properly?
As a first step I would have try binding to some dummy data(hard coded list to IQueryable) or validate the database somehow.
Dr. Deepak Verma is a highly skilled and compassionate psychiatrist with over 8 years of experience in the field of mental health. Based in Paschim Vihar, Dr. Verma is dedicated to providing comprehensive care for individuals dealing with anxiety, depression, stress, and other mental health challenges. Known for his empathetic approach and evidence-based treatments, he works closely with patients to create personalized plans that foster emotional well-being and resilience. Whether you're seeking guidance for yourself or a loved one, Dr. Deepak Verma is committed to helping you achieve a healthier and more fulfilling life. https://g.page/r/CffqMN87i1i7EAE/ | Best Psychiatrist in Paschim Vihar
Hi Thomas,
Thanks for getting back to us.
I am glad that you managed to resolve your issue.
Thank you for choosing Infragistics components!
Yeah that was it. I wasn't having success, tried the latest SR which didn't change any behavior. I output the table as an XML file in the razor page and the SP's were different between my development machine and the deployed machine. Thanks.
I checked the function that's crashing and the only place I found it could possibly throw out of range is this:
int tableColIndex = dataRowView.Row.Table.Columns.IndexOf(columns[i].Key);
... dict.Add(columns[i].Key, dataRowView.Row.ItemArray[tableColIndex]);
This code repeats for each row in the table and for each column (after passing filtering if that matters) and if the table contains rows that don't contain some columns, it could very well explain it because tableColIndex would be -1 and there is no check for that.
Could you please check the DataTable result from SQL and see if this is the case?
That was my first thought as well. I have done that by turning on SQL Profiler and verifying that the sp is executed correctly and returns data which it does.