User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the ASP.NET section within the Web Development category of DaniWeb, a massive community of 392,088 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,931 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our ASP.NET advertiser: Lunarpages ASP Web Hosting
Views: 4756 | Replies: 4
Reply
Join Date: Mar 2007
Posts: 14
Reputation: someoneelse is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
someoneelse someoneelse is offline Offline
Newbie Poster

Help set a dynamic page size for gridview?

  #1  
May 9th, 2007
is there a way to set a set a dynamic page size for gridview?

for instance, i am choosing 10 from the properites window for PageSize, but I would like to have a form field on the page where the user can type the number of records they would like to show per page, and have the gridview reflect that...
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Feb 2005
Location: Braintree, UK
Posts: 1,164
Reputation: hollystyles will become famous soon enough hollystyles will become famous soon enough 
Rep Power: 7
Solved Threads: 58
hollystyles's Avatar
hollystyles hollystyles is offline Offline
Veteran Poster

Re: set a dynamic page size for gridview?

  #2  
May 9th, 2007
  1. protected void ddPageSize_SelectedIndexChange(object sender, EventArgs e)
  2. {
  3. GridView1.PageSize = Convert.ToInt32(ddPageSize.SelectedValue);
  4. //Re-bind the grid however you're doing that, in a seperate function
  5. //if you're sensible.
  6. }
==========================================
Yadda yadda yadda...
Web junky, fevered monkey
Reply With Quote  
Join Date: Mar 2007
Posts: 14
Reputation: someoneelse is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
someoneelse someoneelse is offline Offline
Newbie Poster

Re: set a dynamic page size for gridview?

  #3  
May 10th, 2007
THANKS SO MUCH!

I was able to get this to work with the code snippet you provided!
Reply With Quote  
Join Date: Mar 2007
Posts: 14
Reputation: someoneelse is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
someoneelse someoneelse is offline Offline
Newbie Poster

Help Re: set a dynamic page size for gridview?

  #4  
May 22nd, 2007
I apparen;ty jumped the gun. The problem I have (and this is with and without the dynamic setting for the paging) is as follows:

I have a strange issue. I have a GridView that displays partial data from a table. When you click the "Select" button, I have a form view that shows the entire record. I have paging set to 5. Everything works fine when I view the first set of records. The problem is, when I click the 2nd page, or 3rd, or 4th page, and then click the "Select", it is showing me the first pages records. IE, the gridview is showing in alphabetical order, and when I am on page 10 looking at the T's, and click select, i see the first record, for "A". when I click the second record, I see "A" as well.

No matter what page I am on, it is only using the values from the first view for the select buttons (- I really hope that makes sense...)
Reply With Quote  
Join Date: May 2007
Location: New Brunswick, Canada
Posts: 45
Reputation: mike.mclennan is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
mike.mclennan's Avatar
mike.mclennan mike.mclennan is offline Offline
Light Poster

Re: set a dynamic page size for gridview?

  #5  
May 22nd, 2007
the problem is most likely you are using AutoPostBack on the ASP button object which will reload the page you are on and reset it to the default, which is the first page. The way I usually work around this is my creating my own form button object and use it to complete the task. you might want to think about creating a Refresh button along side the Select, or removing the Select altogether and replacing it with a Form button instead of a ASP object. this may or way not work with what you are trying to do, but it is all I can think of. Hope it helps.
- mike mclennan
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb ASP.NET Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the ASP.NET Forum

All times are GMT -4. The time now is 12:34 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC