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

Getting Index out of bound error

1 Answer 171 Views
ToolTip
This is a migrated thread and some comments may be shown as answers.
Balkar
Top achievements
Rank 1
Balkar asked on 20 Mar 2013, 06:49 PM

Hi, When i tried to bound a datatable, I am getting index out of bound error:

 Dim table As New DataTable()
            table.Columns.Add("CallID", GetType(Integer))
            table.Rows.Add(12345)
            table.Rows.Add(67890)
           dgCallSearch.DataSource =table
           bgCallSearch.databind()



<Telerik:RadGrid ID="dgCallSearch" runat="server" CssClass="DataGridTable" AutoGenerateColumns="false" Visible="true" OnNeedDataSource="dgCallSearch_NeedDataSource1">
<ItemStyle CssClass="DataGridItem"></ItemStyle>
<AlternatingItemStyle CssClass="DataGridItem"></AlternatingItemStyle>
<HeaderStyle CssClass="DataGridHeader"></HeaderStyle>
                                        <MasterTableView>
<Columns>
                                                <Telerik:GridBoundColumn DataField="CallID" HeaderText="ID">

                                                </Telerik:GridBoundColumn>
                                            </Columns>
</MasterTableView>

</Telerik:RadGrid>


Error Log:
System.Web.HttpUnhandledException (0x80004005): Exception of type 'System.Web.HttpUnhandledException' was thrown. ---> System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
   at System.Collections.ArrayList.get_Item(Int32 index)
   at Telerik.Web.UI.GridColumnCollection.System.Web.UI.IStateManager.SaveViewState()
   at Telerik.Web.UI.GridTableView.GetStructureState()
   at Telerik.Web.UI.RadGrid.SaveTableViewStructure(ArrayList stateList, GridTableView tableView)
   at Telerik.Web.UI.RadGrid.SaveViewState()
   at System.Web.UI.Control.SaveViewStateRecursive(ViewStateMode inheritedMode)
   at System.Web.UI.Control.SaveViewStateRecursive(ViewStateMode inheritedMode)
   at System.Web.UI.Control.SaveViewStateRecursive(ViewStateMode inheritedMode)
   at System.Web.UI.Control.SaveViewStateRecursive(ViewStateMode inheritedMode)
   at System.Web.UI.Control.SaveViewStateRecursive(ViewStateMode inheritedMode)
   at System.Web.UI.Control.SaveViewStateRecursive(ViewStateMode inheritedMode)
   at System.Web.UI.Control.SaveViewStateRecursive(ViewStateMode inheritedMode)
   at System.Web.UI.Control.SaveViewStateRecursive(ViewStateMode inheritedMode)
   at System.Web.UI.Control.SaveViewStateRecursive(ViewStateMode inheritedMode)
   at System.Web.UI.Page.SaveAllState()
   at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
   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 PSCU.CUScripter.Web.UI.BasePage.ProcessRequest(HttpContext context) in c:\Projects\CUScripter 3.0\v3.2.0\CUScripter.Common\Web\BasePage.cs:line 343
   at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
   at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

1 Answer, 1 is accepted

Sort by
0
Marin Bratanov
Telerik team
answered on 21 Mar 2013, 12:17 PM
Hi Balkar,

When using the advanced databinding of the grid you should not call the databind() method of the control. Also, the control that gets databound is not the grid whose datasource was just assigned but some other control. Once I remove the call to  bgCallSearch.databind() things worked fine with me. I added the code-behind you pasted in the OnNeedDataSource event handler.

On a side note - I advise that you post your issues in the most relevant section of the forums, because this case is related to RadGrid and not to RadTooltip.


Regards,
Marin Bratanov
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
ToolTip
Asked by
Balkar
Top achievements
Rank 1
Answers by
Marin Bratanov
Telerik team
Share this question
or