944,084 Members | Top Members by Rank

Ad:
  • ASP.NET Discussion Thread
  • Unsolved
  • Views: 21420
  • ASP.NET RSS
May 9th, 2007
0

set a dynamic page size for gridview?

Expand Post »
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...
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
someoneelse is offline Offline
14 posts
since Mar 2007
May 9th, 2007
0

Re: set a dynamic page size for gridview?

ASP.NET Syntax (Toggle Plain Text)
  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. }
Reputation Points: 262
Solved Threads: 68
Veteran Poster
hollystyles is offline Offline
1,181 posts
since Feb 2005
May 10th, 2007
0

Re: set a dynamic page size for gridview?

THANKS SO MUCH!

I was able to get this to work with the code snippet you provided!
Reputation Points: 10
Solved Threads: 0
Newbie Poster
someoneelse is offline Offline
14 posts
since Mar 2007
May 22nd, 2007
0

Re: set a dynamic page size for gridview?

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...)
Reputation Points: 10
Solved Threads: 0
Newbie Poster
someoneelse is offline Offline
14 posts
since Mar 2007
May 22nd, 2007
0

Re: set a dynamic page size for gridview?

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.
Reputation Points: 39
Solved Threads: 0
Light Poster
mike.mclennan is offline Offline
45 posts
since May 2007
Mar 3rd, 2010
0
Re: set a dynamic page size for gridview?
Thank you very much and very Good

By Ake Sarawut
Reputation Points: 10
Solved Threads: 0
Newbie Poster
sarawuthappy is offline Offline
1 posts
since Mar 2010

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in ASP.NET Forum Timeline: PDF to HTML Converter
Next Thread in ASP.NET Forum Timeline: Web Services, .net returning multiple related data





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC