Wrox Programmer Forums
|
ASP.NET 4 General Discussion For ASP.NET 4 discussions not relating to a specific Wrox book
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 4 General Discussion section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 18th, 2011, 09:18 AM
Registered User
 
Join Date: May 2011
Posts: 2
Thanks: 1
Thanked 0 Times in 0 Posts
Default datagrid paging problem

Hello,

I'm new to asp.net and c#. I have a datagrid in my webpage, and I am putting records in the datagrid. I use AllowPaging="True" property of datagrid. In the .cs file I have:

DataGrid1.PageIndexChanged += new DataGridPageChangedEventHandler(DataGrid1_PageInde xChanged);

and

void DataGrid1_PageIndexChanged(Object sender, DataGridPageChangedEventArgs ev)
{
if(!Page.IsPostBack){
DataGrid1.CurrentPageIndex = ev.NewPageIndex;
DataGrid1.DataSource = selectQuery("select users.usr_name from users");
DataGrid1.DataBind();
Page.EnableViewState = true;
}
}

Only the first page is displayed. Anybody can help me?
 
Old May 19th, 2011, 03:01 AM
Registered User
 
Join Date: May 2011
Posts: 6
Thanks: 0
Thanked 1 Time in 1 Post
Default

solution to ur problem is that put your code out of IsPostBack condition like:

void DataGrid1_PageIndexChanged(Object sender, DataGridPageChangedEventArgs ev)
{
DataGrid1.CurrentPageIndex = ev.NewPageIndex;
DataGrid1.DataSource = selectQuery("select users.usr_name from users");
DataGrid1.DataBind();
Page.EnableViewState = true;
}

you can check this article for more info on datagrid paging:

http://www.c-sharpcorner.com/UploadF...gInASPNet.aspx

Regards,
Akaas Developer
http://www.questions-interviews.com/
The Following User Says Thank You to akaas.website For This Useful Post:
rdima (May 19th, 2011)
 
Old May 19th, 2011, 08:59 AM
Registered User
 
Join Date: May 2011
Posts: 2
Thanks: 1
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by akaas.website View Post
solution to ur problem is that put your code out of IsPostBack condition like:

void DataGrid1_PageIndexChanged(Object sender, DataGridPageChangedEventArgs ev)
{
DataGrid1.CurrentPageIndex = ev.NewPageIndex;
DataGrid1.DataSource = selectQuery("select users.usr_name from users");
DataGrid1.DataBind();
Page.EnableViewState = true;
}

you can check this article for more info on datagrid paging:

http://www.c-sharpcorner.com/UploadF...gInASPNet.aspx

Regards,
Akaas Developer
http://www.questions-interviews.com/
Hi,
I just solved the problem, I have put the code in asp page and not in .cs file and it is working. Also I have removed the isPostBack condition
Thanks





Similar Threads
Thread Thread Starter Forum Replies Last Post
DataGrid Paging Problem hoailing22 ASP.NET 1.0 and 1.1 Basics 5 April 23rd, 2006 03:15 AM
Problem in Paging in Datagrid Rahul Gupta ASP.NET 1.0 and 1.1 Basics 0 December 16th, 2005 07:58 AM
DataGrid Paging Problem! zakaria ASP.NET 1.0 and 1.1 Basics 1 April 8th, 2005 06:12 PM
Problem in dataGrid Paging Baby_programmer ASP.NET 1.0 and 1.1 Professional 2 February 23rd, 2005 08:47 PM
DataGrid Paging Problem acyu0318 ASP.NET 1.0 and 1.1 Basics 2 March 2nd, 2004 12:05 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.