Grid throws exception on edit only

2 posts, 0 answers
  1. Paul
    Paul avatar
    27 posts
    Member since:
    Feb 2012

    Posted 27 Jul Link to this post

    So, I have a grid databound in my code behind.  It loads fine, and I built a detail button that works fine.  But when I click on edit, I get: "JavaScript runtime error: Sys.WebForms.PageRequestManagerServerErrorException: Selection out of range Parameter name: value" and when I disable Ajax I can see:
    [ArgumentOutOfRangeException: Selection out of range
    Parameter name: value]
       Telerik.Web.UI.RadComboBox.PerformDataBinding(IEnumerable dataSource) +191
       Telerik.Web.UI.RadComboBox.OnDataSourceViewSelectCallback(IEnumerable data) +509
       System.Web.UI.DataSourceView.Select(DataSourceSelectArguments arguments, DataSourceViewSelectCallback callback) +33
       Telerik.Web.UI.RadComboBox.OnDataBinding(EventArgs e) +1296
       Telerik.Web.UI.RadComboBox.PerformSelect() +37
       System.Web.UI.WebControls.BaseDataBoundControl.DataBind() +30
       Telerik.Web.UI.RadComboBox.DataBind() +71
       System.Web.UI.Control.DataBindChildren() +187
       System.Web.UI.Control.DataBind(Boolean raiseOnDataBinding) +94
       System.Web.UI.Control.DataBind() +15
       System.Web.UI.Control.DataBindChildren() +187
       System.Web.UI.Control.DataBind(Boolean raiseOnDataBinding) +94
       System.Web.UI.Control.DataBind() +15
       System.Web.UI.Control.DataBindChildren() +187
       System.Web.UI.Control.DataBind(Boolean raiseOnDataBinding) +94
       System.Web.UI.Control.DataBind() +15
       System.Web.UI.Control.DataBindChildren() +187
       System.Web.UI.Control.DataBind(Boolean raiseOnDataBinding) +94
       System.Web.UI.Control.DataBind() +15
       System.Web.UI.Control.DataBindChildren() +187
       System.Web.UI.Control.DataBind(Boolean raiseOnDataBinding) +94
       System.Web.UI.Control.DataBind() +15
       System.Web.UI.Control.DataBindChildren() +187
       System.Web.UI.Control.DataBind(Boolean raiseOnDataBinding) +94
       System.Web.UI.Control.DataBind() +15
       System.Web.UI.Control.DataBindChildren() +187
       System.Web.UI.Control.DataBind(Boolean raiseOnDataBinding) +94
       System.Web.UI.Control.DataBind() +15
       System.Web.UI.Control.DataBindChildren() +187
       System.Web.UI.Control.DataBind(Boolean raiseOnDataBinding) +94
       System.Web.UI.Control.DataBind() +15
       System.Web.UI.Control.DataBindChildren() +187
       System.Web.UI.Control.DataBind(Boolean raiseOnDataBinding) +94
       System.Web.UI.Control.DataBind() +15
       Telerik.Web.UI.GridEditFormItem.SetupItem(Boolean dataBind, Object dataItem, GridColumn[] columns, ControlCollection rows) +414
       Telerik.Web.UI.GridItemBuilder.CreateItems(GridGroupingContext group) +998
       Telerik.Web.UI.GridTableView.CreateItems(IEnumerator enumerator, GridColumn[] columns, ControlCollection controls) +211
       Telerik.Web.UI.GridTableView.CreateControlHierarchy(Boolean useDataSource) +2173
       Telerik.Web.UI.GridTableView.CreateChildControls(IEnumerable dataSource, Boolean useDataSource) +865
       System.Web.UI.WebControls.CompositeDataBoundControl.PerformDataBinding(IEnumerable data) +67
       System.Web.UI.WebControls.DataBoundControl.OnDataSourceViewSelectCallback(IEnumerable data) +123
       System.Web.UI.DataSourceView.Select(DataSourceSelectArguments arguments, DataSourceViewSelectCallback callback) +33
       System.Web.UI.WebControls.DataBoundControl.PerformSelect() +138
       Telerik.Web.UI.GridTableView.PerformSelect() +38
       System.Web.UI.WebControls.BaseDataBoundControl.DataBind() +30
       Telerik.Web.UI.GridTableView.DataBind() +382
       Telerik.Web.UI.GridTableView.Rebind() +108
       Telerik.Web.UI.GridCommandEventArgs.ExecuteCommand(Object source) +383
       Telerik.Web.UI.RadGrid.OnBubbleEvent(Object source, EventArgs e) +210
       System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +37
       Telerik.Web.UI.GridItem.OnBubbleEvent(Object source, EventArgs e) +147
       System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +37
       System.Web.UI.WebControls.LinkButton.OnCommand(CommandEventArgs e) +121
       System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String eventArgument) +156
       System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
       System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
       System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +9665314
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1724

    I've been beating my head against this and I can't see a thing wrong with the values I'm getting back from my queries.

    My ASPX is:

    <telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="False"
    CellSpacing="0" GridLines="None" AllowPaging="True"
    DataMember="ID"
    onneeddatasource="RadGrid1_NeedDataSource"
    OnUpdateCommand="RadGrid1_UpdateCommand" PageSize="20"
    onitemcommand="RadGrid1_ItemCommand">
    <MasterTableView DataKeyNames="status,charity,make,model,year,vin,date,id,salePrice,bid,note"
    EditMode="EditForms">
    <CommandItemSettings ExportToPdfText="Export to PDF"></CommandItemSettings>
    <RowIndicatorColumn Visible="True" FilterControlAltText="Filter RowIndicator column">
    <HeaderStyle Width="20px"></HeaderStyle>
    </RowIndicatorColumn>
    <ExpandCollapseColumn Visible="True" FilterControlAltText="Filter ExpandColumn column">
    <HeaderStyle Width="20px"></HeaderStyle>
    </ExpandCollapseColumn>
    <Columns>
    <telerik:GridButtonColumn CommandName="History" Text="History" UniqueName="detailBtn" HeaderText="History" HeaderButtonType="PushButton" AutoPostBackOnFilter="True">
    </telerik:GridButtonColumn>
    <telerik:GridBoundColumn HeaderText="Charity" ItemStyle-Width="140px" FilterControlAltText="Filter column2 column"
    UniqueName="column3" DataType="System.String" DataField="charity" ReadOnly="True">
    <ItemStyle Width="140px"></ItemStyle>
    </telerik:GridBoundColumn>
    <telerik:GridBoundColumn HeaderText="VIN" ItemStyle-Width="140px" FilterControlAltText="Filter column6 column"
    UniqueName="column7" DataType="System.String" DataField="vin" >
    <ItemStyle Width="140px"></ItemStyle>
    </telerik:GridBoundColumn>
    <telerik:GridBoundColumn HeaderText="Year" ItemStyle-Width="140px" FilterControlAltText="Filter column2 column"
    UniqueName="column2" DataType="System.Int32" DataField="year">
    <ItemStyle Width="140px"></ItemStyle>
    </telerik:GridBoundColumn>
    <telerik:GridBoundColumn HeaderText="Make" ItemStyle-Width="140px" FilterControlAltText="Filter column column"
    UniqueName="column" DataType="System.String" DataField="make">
    <ItemStyle Width="140px"></ItemStyle>
    </telerik:GridBoundColumn>
    <telerik:GridBoundColumn HeaderText="Model" ItemStyle-Width="140px" FilterControlAltText="Filter column1 column"
    UniqueName="column1" DataType="System.String" DataField="model">
    <ItemStyle Width="140px"></ItemStyle>
    </telerik:GridBoundColumn>
    <telerik:GridBoundColumn HeaderText="Last Update" ItemStyle-Width="140px" FilterControlAltText="Filter column1 column"
    UniqueName="column5" DataType="System.DateTime" DataField="date" ReadOnly="True">
    <ItemStyle Width="140px"></ItemStyle>
    </telerik:GridBoundColumn>
    <telerik:GridBoundColumn HeaderText="Min. Bid" ItemStyle-Width="140px" FilterControlAltText="Filter column1 column"
    UniqueName="column8" DataType="System.Decimal" DataField="bid" DataFormatString="{0:C}" >
    <ItemStyle Width="140px"></ItemStyle>
    </telerik:GridBoundColumn>
    <telerik:GridBoundColumn HeaderText="Sale Price" ItemStyle-Width="140px" FilterControlAltText="Filter column1 column"
    UniqueName="column6" DataType="System.Decimal" DataField="salePrice" DataFormatString="{0:C}" Display="False">
    <ItemStyle Width="140px"></ItemStyle>
    </telerik:GridBoundColumn>
    <telerik:GridBoundColumn HeaderText="Notes" ItemStyle-Width="140px" FilterControlAltText="Filter column1 column"
    UniqueName="unsoldNotesColumn" DataType="System.String" DataField="note" Display="True">
    <ItemStyle Width="140px"></ItemStyle>
    </telerik:GridBoundColumn>
    <telerik:GridTemplateColumn HeaderText="Latest Status" ItemStyle-Width="240px" AutoPostBackOnFilter="True">
    <ItemTemplate>
    <%#DataBinder.Eval(Container.DataItem, "Status")%>
    </ItemTemplate>
    <EditItemTemplate>
    <telerik:RadComboBox RenderMode="Lightweight" runat="server" ID="updateComboBox" DataTextField="Status"
    DataValueField="ID" DataSourceID="LinqDataSource1" SelectedValue='<%#Bind("ID") %>'
    >
    </telerik:RadComboBox>
    </EditItemTemplate>
    <ItemStyle Width="240px"></ItemStyle>
    </telerik:GridTemplateColumn>
    <telerik:GridEditCommandColumn FooterText="EditCommand footer" UniqueName="EditCommandColumn"
    HeaderText="Edit" HeaderStyle-Width="100px" UpdateText="Update">
    <HeaderStyle Width="100px"></HeaderStyle>
    </telerik:GridEditCommandColumn>


    </Columns>
    <EditFormSettings EditColumn-DataType="System.String">
    <EditColumn FilterControlAltText="Filter EditCommandColumn column"></EditColumn>
    </EditFormSettings>
    </MasterTableView>
    <FilterMenu EnableImageSprites="False"></FilterMenu>
    </telerik:RadGrid>

    And I'm calling my query in the "need data source" event.

     

     

    I'd be very very grateful for any advice!


  2. Viktor Tachev
    Admin
    Viktor Tachev avatar
    1488 posts

    Posted 01 Aug Link to this post

    Hi Paul,

    I have examined the provided code and it looks mostly correct. I noticed that the DataMember property is set for the grid. Note that this property is used to specify a specific set of data that will be used by the RadGrid (e.g. if you have a DataSet as data source you can use the DataMember to specify which DataTable will be used as source by the grid.).

    However, in your scenario it seems that DataMember is pointing to a field from the data source. Please remove DataMember from the markup and see how the behavior changes.

    On a side note, make sure that DataBind is not used anywhere in the code-behind for the RadGrid.

    In case the issue persists please send us the complete markup with the related code-behind so we can examine it.

    Regards,
    Viktor Tachev
    Telerik by Progress
    Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top