Index was out of range. Must be non-negative and less than the size of the collection. Parameter: In
Posted
by user356973
on Stack Overflow
See other posts from Stack Overflow
or by user356973
Published on 2010-06-11T20:36:20Z
Indexed on
2010/06/11
20:42 UTC
Read the original article
Hit count: 921
Dear Telerik Team,
When I am trying to display data using radgrid I am getting error like "Index was out of range. Must be non-negative and less than the size of the collection. Parameter: Index".
Here is my code
<telerik:RadGrid ID="gvCktMap" BorderColor="White" runat="server" AutoGenerateColumns="true"
AllowSorting="true" BackColor="White" AllowPaging="true" PageSize="25" GridLines="None"
OnPageIndexChanging="gvCktMap_PageIndexChanging" OnRowCancelingEdit="gvCktMap_RowCancelingEdit"
OnRowCommand="gvCktMap_RowCommand" OnRowUpdating="gvCktMap_RowUpdating" OnRowDataBound="gvCktMap_RowDataBound"
OnSorting="gvCktMap_Sorting" OnRowEditing="gvCktMap_RowEditing" ShowGroupPanel="True"
EnableHeaderContextMenu="true" EnableHeaderContextFilterMenu="true" AllowMultiRowSelection="true"
AllowFilteringByColumn="True" AllowCustomPaging="false" OnItemCreated="gvCktMap_ItemCreated"
EnableViewState="false" OnNeedDataSource="gvCktMap_NeedDataSource" OnItemUpdated="gvCktMap_ItemUpdated"
>
<MasterTableView DataKeyNames="sId" UseAllDataFields="true">
<Columns>
<telerik:GridBoundColumn UniqueName="sId" HeaderText="sId" DataField="sId" Visible="false">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn UniqueName="orderId" HeaderText="orderId" DataField="orderId">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn UniqueName="REJ" HeaderText="REJ" DataField="REJ">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn UniqueName="Desc" HeaderText="Desc" DataField="Desc">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn UniqueName="CustomerName" HeaderText="CustomerName" DataField="CustomerName">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn UniqueName="MarketName" HeaderText="MarketName" DataField="MarketName">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn UniqueName="HeadendName" HeaderText="HeadendName" DataField="HeadendName">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn UniqueName="SiteName" HeaderText="SiteName" DataField="SiteName">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn UniqueName="TaskStatus" HeaderText="TaskStatus" DataField="TaskStatus">
</telerik:GridBoundColumn>
</Columns>
</telerik:RadGrid>
Here is my code behind
private void bingGrid()
{
try
{
gvCktMap.Columns.Clear();
DataSet dsResult = new DataSet();
DataSet dsEditItems = new DataSet();
dsEditItems.ReadXml(Server.MapPath("XMLS/" + Session["TaskID"].ToString() + ".xml"));
clsSearch_BL clsObj = new clsSearch_BL();
clsObj.TaskID = (string)Session["TaskID"];
clsObj.CustName = (string)Session["CustName"];
clsObj.MarketName = (string)Session["MarketName"];
clsObj.HeadendName = (string)Session["HeadendName"];
clsObj.SiteName = (string)Session["SiteName"];
clsObj.TaskStatus = (string)Session["TaskStatus"];
clsObj.OrdType = (string)Session["OrdType"];
clsObj.OrdStatus = (string)Session["OrdStatus"];
clsObj.ProName = (string)Session["ProName"];
clsObj.LOC = (string)Session["LOC"];
dsResult = clsObj.getSearchResults_BL(clsObj);
Session["SearchRes"] = dsResult;
DataTable dtFilter = new DataTable();
DataColumn dtCol = new DataColumn("FilterBy");
dtFilter.Columns.Add(dtCol);
dtCol = new DataColumn("DataType");
dtFilter.Columns.Add(dtCol);
gvCktMap.DataSource = dsResult;
gvCktMap.DataBind();
}
catch (Exception ex)
{
}
}
If i remove <MasterTableView></MasterTableView>
Its working fine without any error. But for some reasons i need to use <MasterTableView></MasterTableView>
Can anyone help me out to fix this error.
Thanks In Advance
© Stack Overflow or respective owner