Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > GridView's Paging feature not working!

Reply
Thread Tools

GridView's Paging feature not working!

 
 
Guest
Posts: n/a
 
      12-21-2005
Hello,

I have a GridView in my ASP.NET 2.0 application that performs the paging
feature perfect when I have it bound to a data source.

But now I have it bound to a dataset and the paging feature will not work.

When I try to use paging I get this error:

The GridView 'gvResults' fired event PageIndexChanging which wasn't handled.

I realize that the PageIndexChanging event was not handled. How do I handle
this event if I am using a dataset as the data source of the gridview
control?

Additionally, I have to use the dataset as the data source because I do alot
of filtering and other stuff.

Thanks,

J


 
Reply With Quote
 
 
 
 
bhawin13
Guest
Posts: n/a
 
      12-22-2005
Hello,
Check out is there function which contains GridView1_PageIndexChanging
or something like that.

If such funcation not exist then select your grid in designer go to
property window click on event button. then double click on
OnSortCommand value field. It will generate event for you.

Regarding paging code in that event find article on 4GuysFromRolla.com
or DataGridGirl.com.

Correct me if I am wrong.
bhawin13

 
Reply With Quote
 
 
 
 
Steven Cheng[MSFT]
Guest
Posts: n/a
 
      12-22-2005
Hi J,

When you manually bind DataSet to GridView, we'll need to manually handle
the paging work (register the PageIndexChanging event handler and bind the
new page data to Gridview...). In the aspx , we need to specify the
PageIndexChanging event handler as below:

<asp:GridView ID="GridView1" runat="server" AllowPaging="True"
OnPageIndexChanging="GridView1_PageIndexChanging"
PageSize="5">


The page's code behind is something like:

GetDataSource() function is just a test funciton I used to return a
certain DataSet that contains some data.....
======================================

public partial class GridViews_GridViewManualPaging : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
GridView1.DataSource = GetDataSource();
GridView1.DataMember = "items";
GridView1.DataBind();
}
}
protected void GridView1_PageIndexChanging(object sender,
GridViewPageEventArgs e)
{
Response.Write("<br>NewpageIndex: " + e.NewPageIndex);
GridView1.PageIndex = e.NewPageIndex;
GridView1.DataSource = GetDataSource();
GridView1.DataBind();
}

private DataSet GetDataSource()
{
DataSet ds = new DataSet();
DataTable dt = new DataTable("items");
dt.Columns.Add("id", typeof(long));
dt.Columns.Add("name", typeof(string));

for (int i = 0; i < 50; i++)
{
DataRow dr = dt.NewRow();
dr[0] = i + 1;
dr[1] = "Item" + dr[0];
dt.Rows.Add(dr);
}

ds.Tables.Add(dt);

return ds;
}
}
=====================

Hope helps. Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
--------------------
| Reply-To: <(E-Mail Removed)>
| From: <(E-Mail Removed)>
| Subject: GridView's Paging feature not working!
| Date: Wed, 21 Dec 2005 14:40:19 -0800
| Lines: 23
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2900.2670
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2670
| X-RFC2646: Format=Flowed; Original
| Message-ID: <uz3jE#(E-Mail Removed)>
| Newsgroups: microsoft.public.dotnet.framework.aspnet
| NNTP-Posting-Host: ip-206.159.118.137.hdiss.net 206.159.118.137
| Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFT NGP09.phx.gbl
| Xref: TK2MSFTNGXA02.phx.gbl
microsoft.public.dotnet.framework.aspnet:366424
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
|
| Hello,
|
| I have a GridView in my ASP.NET 2.0 application that performs the paging
| feature perfect when I have it bound to a data source.
|
| But now I have it bound to a dataset and the paging feature will not work.
|
| When I try to use paging I get this error:
|
| The GridView 'gvResults' fired event PageIndexChanging which wasn't
handled.
|
| I realize that the PageIndexChanging event was not handled. How do I
handle
| this event if I am using a dataset as the data source of the gridview
| control?
|
| Additionally, I have to use the dataset as the data source because I do
alot
| of filtering and other stuff.
|
| Thanks,
|
| J
|
|
|

 
Reply With Quote
 
manju.cdtech manju.cdtech is offline
Junior Member
Join Date: May 2007
Posts: 1
 
      05-12-2007
see this http://forums.asp.net/thread/1177923.aspx
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Does GridView paging feature limit number of records coming back from database? Ronald S. Cook ASP .Net 3 05-06-2007 06:20 PM
Combining numeric mode paging and nextPreview paging in datagrid Red ASP .Net 1 03-12-2005 11:41 PM
datagrid paging - customising paging style wh1974 ASP .Net 0 01-12-2005 03:48 PM
DataSet paging vs Datareader paging =?Utf-8?B?UGF0cmljay5PLklnZQ==?= ASP .Net 1 10-08-2004 02:13 PM
Paging Dr. Who, Paging Dr. Who... Father_Sicko@TheOrphanage.com Computer Security 1 07-02-2004 08:59 PM



Advertisments