Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / ASP.NET > Grid > Selection out of range after deleting record
RadControls for ASP.NET are no longer supported (see this page for reference). In case you have inquiries about the Telerik ASP.NET AJAX controls, post them in the pertinent ASP.NET AJAX forums.

Not answered Selection out of range after deleting record

Feed from this thread
  • Joshua Warren avatar

    Posted on Jun 16, 2010 (permalink)

    I have a radgrid and use a custom filter instead of the regular filter provided with the radgrid.  The filter is a radcombobox.  The datasource for the radgrid is a SQLDataSource.  The select statement for it is: select car_make, car_model from cars.  The datasource for the radcombobox is a SQLDatasource.  The select statement for it is: select distinct car_make from cars.  Obviously, the radcombobox is the filter for the car_make column.

    Well, this works fine, unless I have used the filter and it only returns one row, and I attempt to delete that row.  Upon trying to delete it, I get the error:

    Message: Sys.WebForms.PageRequestManagerServerErrorException: Selection out of range
    Parameter name: value

    Once I refresh the page, the custom filter is no longer being used, and the row was in fact deleted.

    Anyone have any ideas on how to keep the error from happening??

    Thanks in advance,

    Joshua



  • Pavlina Pavlina admin's avatar

    Posted on Jun 21, 2010 (permalink)

    Hi Joshua,

    Could you provide your aspx mark-up and code-behind (please, use the CodeFormatter tool of the editor to paste the code) or alternatively open up a formal support ticket and send a small test project to debug. It is important to know how you are creating the grid structure and binding the control.

    Thank you.

    Best wishes,
    Pavlina
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

  • GlenB avatar

    Posted on Jun 8, 2011 (permalink)

    I have discovered the exact same problem.

    I have a radgrid filtered by a (Hospital) combobox. If the filter only returns 1 matching item and then I modify the Hospital in that record (effectively removing the match) I get the error: Sys.WebForms.PageRequestManagerServerErrorException: Selection out of range when I return to the grid. This does not occur when there are matching items left.

    The relevant RadGrid code is:
    <telerik:GridBoundColumn DataField="Hospitalname" HeaderText="Hospital" SortExpression="Hospitalname"
        UniqueName="Hospitalname" CurrentFilterFunction="Contains" AutoPostBackOnFilter="true">
        <FilterTemplate>
            <telerik:RadComboBox ID="RadComboBoxTitle" DataSourceID="ds_Hospitals" DataTextField="Hospitalname"
                DataValueField="Hospitalname" AppendDataBoundItems="true" SelectedValue='<%# TryCast(Container,GridItem).OwnerTableView.GetColumn("Hospitalname").CurrentFilterValue %>'
                runat="server" OnClientSelectedIndexChanged="TitleIndexChanged">
                <Items>
                    <telerik:RadComboBoxItem Text="All" />
                </Items>
            </telerik:RadComboBox>
            <telerik:RadScriptBlock ID="RadScriptBlock2" runat="server">
                <script type="text/javascript">
                    function TitleIndexChanged(sender, args) {
                        var tableView = $find("<%# TryCast(Container,GridItem).OwnerTableView.ClientID %>");
                        tableView.filter("Hospitalname", args.get_item().get_value(), "EqualTo");
                    }
                </script>
            </telerik:RadScriptBlock>
        </FilterTemplate>
    </telerik:GridBoundColumn>
    My SQLDataSource is:
    <asp:SqlDataSource ID="ds_Hospitals" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
        SelectCommand="SELECT DISTINCT Hospitals.Hospitalname FROM Sub_Cases INNER JOIN Hospitals ON Sub_Cases.HospID = Hospitals.HospID WHERE Sub_Cases.UserID = @UserID">
        <SelectParameters>
            <asp:CookieParameter CookieName="UserID" Name="UserID" Type="Int32" />
        </SelectParameters>
    </asp:SqlDataSource>

    The edit function is being performed in a RadWindow (different page) and when the window is closed a JS function rebinds the grid.

    I did some testing on the other filters and discovered that the error only occurs when filtered by a RadComboBox (ie: if i filter by date and then change the date on the only matching record, the grid correctly shows the No Records Template).

  • Pavlina Pavlina admin's avatar

    Posted on Jun 13, 2011 (permalink)

    Hi GlenB,

    Have you compared your implementation with this presented in the following online demo of the product:

    http://demos.telerik.com/aspnet-ajax/grid/examples/programming/filtertemplate/defaultcs.aspx

    Can you outline the differences between this case and your configuration? They can lead us to the source of the problem to address it accordingly.

    Kind regards,
    Pavlina
    the Telerik team

    Consider using RadControls for ASP.NET AJAX (built on top of the ASP.NET AJAX framework) as a replacement for the Telerik ASP.NET Classic controls, See the product support lifecycle here.

  • GlenB avatar

    Posted on Jun 16, 2011 (permalink)

    The difference between the 2 is that in your demo there is no way to remove or edit a filtered item to reproduce the error. Otherwise for the purposes of the error I am getting there is no difference!

    Can you please try filtering a radgrid using a combobox and then remove the last matching record and see what happens - I am sure you will reproduce the fault.

  • Pavlina Pavlina admin's avatar

    Posted on Jun 22, 2011 (permalink)

    Hello Glen,

    Based on this information, it is hard to determine what is causing this error. If the issue persists, you can open a formal support ticket, and send us a small working project, demonstrating your setup, and the unwanted behavior. We will review it locally, and advise you further.

    All the best,
    Pavlina
    the Telerik team

    Consider using RadControls for ASP.NET AJAX (built on top of the ASP.NET AJAX framework) as a replacement for the Telerik ASP.NET Classic controls, See the product support lifecycle here.

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / ASP.NET > Grid > Selection out of range after deleting record