473,387 Members | 1,925 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

GridView's Paging feature not working!

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
Dec 21 '05 #1
2 16306
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

Dec 22 '05 #2
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: <wa********@newsgroups.nospam>
| From: <wa********@newsgroups.nospam>
| 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: <uz**************@TK2MSFTNGP09.phx.gbl>
| 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
|
|
|

Dec 22 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: ck388 | last post by:
For some reason when I enable the callback feature of the gridview I still get a page refresh, that is it seems like there is a postback that occurs, not a callback which is just supposed to update...
1
by: davidjgonzalez | last post by:
I have a GridView that has paging enabled. Each item (as defined in an ItemTemplate) includes several controls which have operations i would like to Atlas-enable. Everything is working well except...
8
by: Greg Lyles | last post by:
Hi all, I'm trying to develop an ASP.NET 2.0 website and am running into some real problems with what I thought would be a relatively simple thing to do. In a nutshell, I'm stuck on trying to...
4
by: Jonathan Wood | last post by:
Okay, I spent about 3 hours getting the GridView control to do what I needed. Basically, I set the control's AutoGenerateColumns to False and then defined a single template column (which I will...
2
by: antonyliu2002 | last post by:
I've been googling for some time, and could not find the solution to this problem. I am testing the paging feature of gridview. I have a very simple web form on which the user can select a few...
5
by: Andrew Robinson | last post by:
I am attempting to better automate a Pager Template within a GridView. I am succesfully skinning a Drop Down List withing my control (the DDL is added to my control). I correctly populate the item...
3
by: Ronald S. Cook | last post by:
I was told that if calling lots of records from the database (let's say 100,000), that the GridView's paging feature would automatically "handle" everything. But the 100,000 records are still...
0
JustRun
by: JustRun | last post by:
Hi, This is the first time to work with ASP.NET. I had a customized membership gridview, the problem is i can't enable paging feature or sorting. 1 protected DataSet MyGetAllUsers() 2 ...
4
by: Peter | last post by:
I want to call a JavaScript on PageIndexChanged event, how do I do that? Thank You Peter
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.