Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
180
WebDataGrid - Index was outside the bounds of the array
posted

Hi,

         I have an editable grid within a user control being rendered from another user control which in turn are rendered from master page.

While the initial loading and display of the grid works fine, but when there is a post back of the page(Eg when a button is clicked) it throws the below error:

Error is thrown before the Server side event of click Button is triggered.

The ColumnSorted event is also not hit before the error is thrown.

DataBind happens in the page_load event of the user control  where we dynamically load the data into the WebDataGrid.

How to resolve this?

Index was outside the bounds of the array.

Stack Trace:

at Infragistics.Web.UI.GridControls.Sorting.LoadClientCollections(Object[] data)
at Infragistics.Web.UI.Framework.ObjectBase.LoadClientState(Object[] oData)
at Infragistics.Web.UI.Framework.ObjectBase.Infragistics.Web.UI.IClientState.LoadClientState(Object[] oData)
at Infragistics.Web.UI.GridControls.GridBot.LoadClientCollections(Object[] collections)
at Infragistics.Web.UI.Framework.RunBot.LoadClientData()
at Infragistics.Web.UI.GridControls.WebDataGrid.OnInit(EventArgs e)
at System.Web.UI.Control.InitRecursive(Control namingContainer)
at System.Web.UI.Control.InitRecursive(Control namingContainer)
at System.Web.UI.Control.InitRecursive(Control namingContainer)
at System.Web.UI.Control.InitRecursive(Control namingContainer)
at System.Web.UI.Control.InitRecursive(Control namingContainer)
at System.Web.UI.Control.InitRecursive(Control namingContainer)
at System.Web.UI.Control.AddedControl(Control control, Int32 index)
at System.Web.UI.ControlCollection.Add(Control child)
at System.Web.UI.HtmlControls.HtmlTable.HtmlTableRowControlCollection.Add(Control child)
at System.Web.UI.ControlCollection.AddAt(Int32 index, Control child)
at System.Web.UI.HtmlControls.HtmlTable.HtmlTableRowControlCollection.AddAt(Int32 index, Control child)
at System.Web.UI.HtmlControls.HtmlTableRowCollection.Add(HtmlTableRow row)
at ASPNetPortal.DesktopDefault.Page_Init(Object sender, EventArgs e) in Default.aspx.vb:line 165
at System.Web.UI.Control.OnInit(EventArgs e)
at System.Web.UI.Page.OnInit(EventArgs e)
at System.Web.UI.Control.InitRecursive(Control namingContainer)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

Target Site:

{Void LoadClientCollections(System.Object[])}

.Ascx->

<asp:panel id="pnlModuleContent" style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; PADDING-BOTTOM: 0px; PADDING-TOP: 0px" runat="server" cssclass="WideModule">
	<asp:PlaceHolder id="plhFilterContents" Runat="server"></asp:PlaceHolder>
    <asp:ScriptManagerProxy runat="server"></asp:ScriptManagerProxy>
            <ig:WebExcelExporter ID="eExporter" runat="server"></ig:WebExcelExporter>
            <ig:WebDataGrid 
                ID="grdDataTable" 
                runat="server" 
                AutoGenerateColumns="true" 
                width="100%"  
                ClientIDMode="Static" 
                EnableDataViewState ="true" 
                EnableViewState ="true"
                HeaderCaptionCssClass="WebDataGridColumnHeader" 
                ItemCssClass = "WebDataGridRow"
                AltItemCssClass = "WebDataGridAlternating"
                OnColumnSorted="grdDataTable_SortColumn"
                OnPageIndexChanged="grdDataTable_PageIndexChanged"
                OnInitializeRow="grdDataTable_InitializeRow" 
                EnableAjax ="true"
                OnRowAdding="grdDataTable_RowAdding"       
                OnRowUpdating="grdDataTable_RowUpdating">
                <Behaviors>
                    <ig:Selection CellClickAction="Row" CellSelectType="Single" RowSelectType="Single" SelectedRowSelectorCssClass="DataGridSelectedRow" >
                        <SelectionClientEvents RowSelectionChanged="RowSelection_Changed" />
                    </ig:Selection>
                    <ig:Paging PagerAppearance="Bottom" PageSize="100" Enabled="true" />
                    <ig:Sorting SortingMode="Single" Enabled="true" />
                    <ig:ColumnResizing Enabled="false" />
                    <ig:EditingCore Enabled="false" EnableInheritance="false" AutoCRUD="false" BatchUpdating="true">
                        <EditingClientEvents CellValueChanged="EditingEvents_CellValueChanged" RowAdding="EditingEvents_RowAdding" />
                        <Behaviors>
                            <ig:RowAdding Enabled="false" EnableInheritance="false" Alignment="Bottom">
                                <EditModeActions EnableOnActive="true" MouseClick="Single" />  
                             </ig:RowAdding>
                            <ig:RowEditing Enabled="false" EnableInheritance="false">                                                                
                                <EditModeActions EnableOnActive="true" MouseClick="Single" />
                                <RowEditingClientEvents EnteringEditMode="RowEditing_EnteringEditMode" ExitedEditMode="RowEditing_ExitedEditMode" />    
                                <ColumnSettings>
                                                <ig:EditingColumnSetting  ReadOnly="true" />
                                </ColumnSettings>                             
                            </ig:RowEditing>                   
                        </Behaviors>                        
                    </ig:EditingCore>
                    <%--<ig:EditingCore Enabled="false">
                    </ig:EditingCore>--%>
                    <ig:Activation></ig:Activation> 
                </Behaviors>
            <ClientEvents  Initialize="Initialize"   />
            </ig:WebDataGrid>
	<asp:datagrid id="dgHidden" visible="False" runat="server" autogeneratecolumns="True" headerstyle-cssclass="ListHead"></asp:datagrid>
	<INPUT id="hdnEditRow" type="hidden" value="-1" name="hdnEditRow" runat="server" />
	<asp:label id="lblApplicationError" visible="True" runat="server" cssclass="ErrorMessage" enableviewstate="false"></asp:label>
	<DIV align="left" style="vertical-align:middle">
		<asp:label id="lblNoData" visible="False" runat="server" cssclass="normal">No data available.</asp:label>
	</DIV>
</asp:panel>

Server Side (Related to Sorting):

Protected Sub grdDataTable_SortColumn(sender As Object, e As SortingEventArgs) Handles grdDataTable.ColumnSorted
Dim i As Integer
Dim gridRefreshed As Boolean = False

RaiseEvent GridNeedsDataRefresh()
gridRefreshed = True

' 12/17/2004 BWM: Check if the grid was already refresh above, otherwise the it will be refreshed twice.
If grdDataTable.Behaviors.Paging.Enabled And Not gridRefreshed Then
RaiseEvent PagedGridNeedsDataRefresh()
End If
End Sub

Thanks,

Aravind