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

[Solved] paging and sorting crash when using NeedDataSource event

6 Answers 385 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jean-François Fortier
Top achievements
Rank 1
Jean-François Fortier asked on 28 May 2008, 09:11 PM
Trying this simple example to use paging and sorting  when using when using NeedDataSource event

My example is base on this online live demo:
http://www.telerik.com/demos/aspnet/prometheus/Grid/Examples/Programming/NeedDataSource/DefaultCS.aspx

(I am using this version :RadControls_for_ASP.NET_AJAX_2008_1_515_dev.exe)

Strangly my code is very similar but somehow when i start sorting and paging i either get an empty page or and eroor like this :

Index 15 is either negative or above rows count. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.IndexOutOfRangeException: Index 15 is either negative or above rows count.

Strange because the live demo while using very similar code, work but not my code!

Here my example, you can see its pretty close to the live demo (see the previous link)


.cs:

using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

namespace WebApplication1
{
    public partial class _Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!this.IsPostBack)
            {
               
            }
        }

        protected void RadGrid1_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
        {
            DataTable table = new DataTable();
            table.Columns.Add("FirstName", typeof(string));
            table.Columns.Add("LastName", typeof(string));

            table.Rows.Add(new object[] { "Joe1","Brown1"});
            table.Rows.Add(new object[] { "Joe2", "Brown2" });
            table.Rows.Add(new object[] { "Joe3", "Brown3" });
            table.Rows.Add(new object[] { "Joe4", "Brown4" });
            table.Rows.Add(new object[] { "Joe5", "Brown5" });
            table.Rows.Add(new object[] { "Joe6", "Brown6" });
            table.Rows.Add(new object[] { "Joe7", "Brown7" });
            table.Rows.Add(new object[] { "Joe8", "Brown8" });
            table.Rows.Add(new object[] { "Joe9", "Brown9" });
            table.Rows.Add(new object[] { "Joe10", "Brown10" });
            table.Rows.Add(new object[] { "Joe11", "Brown11" });
            table.Rows.Add(new object[] { "Joe12", "Brown12" });
            table.Rows.Add(new object[] { "Joe13", "Brown13" });
            table.Rows.Add(new object[] { "Joe14", "Brown14" });
            table.Rows.Add(new object[] { "Joe15", "Brown15" });
            table.Rows.Add(new object[] { "Joe16", "Brown16" });
            table.Rows.Add(new object[] { "Joe17", "Brown17" });
            table.Rows.Add(new object[] { "Joe18", "Brown18" });
            table.Rows.Add(new object[] { "Joe19", "Brown19" });
            table.Rows.Add(new object[] { "Joe20", "Brown2" });
           
            table.Rows.Add(new object[] { "Jane1", "Smith1" });
            table.Rows.Add(new object[] { "Jane2", "Smith2" });
            table.Rows.Add(new object[] { "Jane3", "Smith3" });
            table.Rows.Add(new object[] { "Jane4", "Smith4" });
            table.Rows.Add(new object[] { "Jane5", "Smith5" });
            table.Rows.Add(new object[] { "Jane6", "Smith6" });
            table.Rows.Add(new object[] { "Jane7", "Smith7" });
            table.Rows.Add(new object[] { "Jane8", "Smith8" });
            table.Rows.Add(new object[] { "Jane9", "Smith9" });
            table.Rows.Add(new object[] { "Jane10", "Smith10" });
            table.Rows.Add(new object[] { "Jane11", "Smith11" });
            table.Rows.Add(new object[] { "Jane12", "Smith12" });
            table.Rows.Add(new object[] { "Jane13", "Smith13" });
            table.Rows.Add(new object[] { "Jane14", "Smith14" });
            table.Rows.Add(new object[] { "Jane15", "Smith15" });
            table.Rows.Add(new object[] { "Jane16", "Smith16" });
            table.Rows.Add(new object[] { "Jane17", "Smith17" });
            table.Rows.Add(new object[] { "Jane18", "Smith18" });
            table.Rows.Add(new object[] { "Jane19", "Smith19" });
            table.Rows.Add(new object[] { "Jane20", "Smith2" });

            RadGrid1.DataSource = table;
           

        }

     

       
    }
}

.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApplication1._Default" %>

<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>

    <telerik:RadGrid ID="RadGrid1" Skin="Office2007" Width="97%" AllowSorting="True"
        PageSize="15" ShowFooter="True" AllowPaging="True" AllowMultiRowSelection="True"
        runat="server" GridLines="None" OnNeedDataSource="RadGrid1_NeedDataSource">
        <MasterTableView Width="100%" />
        <PagerStyle Mode="NextPrevAndNumeric" />
    </telerik:RadGrid>
    </form>
</body>
</html>

Can anyone help on this matter ?

6 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 29 May 2008, 05:26 AM
Hi Jean-François,

You can find the latest build in your support ticket.

Best wishes,
Vlad
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Chad Chenoweth
Top achievements
Rank 1
answered on 29 May 2008, 04:17 PM
I'm having the same issue.  Can you send me the latest build as well?
0
Vlad
Telerik team
answered on 29 May 2008, 04:23 PM
Hi Chad,

Please open a formal support ticket and we send you latest Telerik.Web.UI build.

Greetings,
Vlad
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
VANDENBERGHE
Top achievements
Rank 1
answered on 09 Jun 2008, 09:02 AM
Hi,

I have exactly the same issue with the 2008.1.515.35 version. I'm testing your component to make a demo to my manager before choosing your library and I really need my grid working good, could you send me your latest build ?

Or is there another way to make the grid working without this issue ?

Thanks in advance.
0
Sebastian
Telerik team
answered on 09 Jun 2008, 10:43 AM
Hi VANDENBERGHE,

I am attaching the latest internal trial build of RadControls for ASP.NET AJAX (2008.1.609) to this support thread. Please follow the upgrade instructions from the following KB article:

http://www.telerik.com/support/kb/article/b454K-kad-b454T-bah-b454c-bah.aspx

and let us know whether everything is OK after the update.

Greetings,
Stephen
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
VANDENBERGHE
Top achievements
Rank 1
answered on 09 Jun 2008, 11:16 AM
Thanks a lot It works for me, I can't reproduce this bug anymore.

Regards,
Sebastien
Tags
Grid
Asked by
Jean-François Fortier
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Chad Chenoweth
Top achievements
Rank 1
VANDENBERGHE
Top achievements
Rank 1
Sebastian
Telerik team
Share this question
or