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;
.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 ?
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 ?
