Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > .NET > Other .NET > General .NET
Password Reminder
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
General .NET For general discussion of MICROSOFT .NET topics that don't fall within any of the other .NET forum subcategories or .NET language forums.  If your question is specific to a language (C# or Visual Basic) or type of application (Windows Forms or ASP.Net) try an applicable forum category. ** PLEASE BE SPECIFIC WITH YOUR QUESTION ** When posting here, provide details regarding the Microsoft .NET language you are using and/or what type of application (Windows/Web Forms, etc) you are working in, if applicable to the question. This will help others answer the question without having to ask.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the General .NET section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old August 11th, 2004, 11:16 PM
Authorized User
Join Date: Aug 2004
Location: , , .
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
Default Limit rows returned and next rows

I use C#.NET

I have sql statement. This sql statement return too many rows.

The firstly show, I want to show 20 rows on my .aspx web page.

When I click "Next page 20 items" label, then return next 20 items and repeat until no rows.

When I click "Previous page 20 items" then return previous 20 items and repeat until first 20 rows.

How did I do that?

Thank you so much.

Best regards,

Minh Phan.

Reply With Quote
  #2 (permalink)  
Old August 12th, 2004, 06:25 AM
Friend of Wrox
Join Date: Oct 2003
Location: Chennai, TamilNadu, India.
Posts: 326
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to Santhi Send a message via MSN to Santhi

If you are using datagrid to display the records then Set the Paging & CustomPaging property of the DataGrid to true and pagesize to 20.

See the sample below:

private void Page_Load(object sender, System.EventArgs e)
{ // Put user code to initialize the page here
private void BindGrid(int st,int nt){
    string sqlconn;
    string strSql;
     SqlConnection conn=new SqlConnection(sqlconn);
    strSql="select job_id,job_desc,min_lvl,max_lvl from jobs where job_id>="+st+" and job_id<="+nt+"";
        SqlDataAdapter strAdap=new SqlDataAdapter(strSql,conn);
    DataSet ds=new DataSet();
private void InitializeComponent()
    this.DataGrid1.PageIndexChanged += new System.Web.UI.WebControls.DataGridPageChangedEvent Handler(this.DataGrid1_PageIndexChanged);
     this.Load += new System.EventHandler(this.Page_Load);
private void DataGrid1_PageIndexChanged(object source, System.Web.UI.WebControls.DataGridPageChangedEvent Args e)
   DataGrid1.CurrentPageIndex = e.NewPageIndex;
   BindGrid((e.NewPageIndex *DataGrid1.PageSize)+1,(e.NewPageIndex* DataGrid1.PageSize)+DataGrid1.PageSize);

Here BindGrid() function is used to bind the data's to the datagrid and VirtualItemCount property allows the control to determine the total number of pages needed to display every item in the DataGrid control.

Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
column to rows mitasid Beginning VB 6 1 June 12th, 2006 01:37 PM
selecting rows returned by executing a SP dsekar_nat SQL Server 2000 4 May 11th, 2006 11:12 AM
Outputto exceeded limit of rows Renee Voice Access VBA 2 February 26th, 2006 04:47 PM
duplicate rows msrnivas Classic ASP Components 1 August 26th, 2004 02:07 AM
limit rows returned in a list box stoneman Access 1 January 16th, 2004 10:46 PM

All times are GMT -4. The time now is 04:14 AM.

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