472,119 Members | 1,458 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

Pagination User Control + Class problems (C#)

346 Expert 100+

For starters:

Yes, I am new to asp.net, however I hold a good 9-10 years of experience working with classic asp and am only just now upgrading my skills. I'm picking asp.net up pretty quickly but I'm running into a stumbling block that I just can't seem to get around. I think I know what the problem is, and I'm pretty confident in a work around, but it's not quite what I had hoped for so I thought I'd pick some of the experts brains to see what they think :)

I can't stand those bogus cookie cutter frontpage on drugs gridview dealios. I hated them the second I was introduced to them for the sole reason that one loses control over their data and exactly how that data gets displayed. So, I set out to "correct" that little problem and as such, I may be making my life a little bit more difficult than it has to be right now - but I'm confident it will pay off 100 fold in the future.

I found the repeater control after a few hours and I immediately fell in love. I still didn't like the dozens of lines worth of code in my code behind file that are necessary to support sorting, pagination, and binding the actual data to my repeater - so I set out to set it all up into an easy to use, customizable class object. I've done that, for the most part - but i am running into one LAST little hiccup... (figures, huh!?)

I set the pagination up into a Web User Control and I have that user control set up wonderfully. It displays the correct amount of pages, the next buttons and previous buttons appear and disappear when they are supposed to, the page changing pages. There are only two things I need to tell the custom control, and only one of those two things changes frequently.

1) How many pages are there in total.
2) Which page are we currently on

Obviouly, we need to track which page we are on.. so I set up a method in my class to do just that. It simply gets or sets an integer. That method is then called to change the CurrentPageIndex of my PagedDataSource.

The problem is, upon clickage of the "page" or "next" or "previous" buttons in the pagination control - the page/class seems to load BEFORE the new value gets set!

It's my suspicion that this is the way the compiler works - it first loads the class object, and then loads the page and deals with whatever from there.

If this is the case, It doesn't matter what I set the current page method to, it will always feed an OLD value to the pageddatasource's CurrentPageIndex .

I have tried using the session instead, and even the viewstate to track and pass the value to the class object but it makes no difference, and if the above is true it stands to reason.

Can anyone suggest a workaround for this? I can think of perhaps using the querystring to track which page.. but that's just so ugly, isnt it?

Would appreciate all the advice you experts can give on this one!

Apr 15 '09 #1
1 3416
346 Expert 100+
Oh, and i can provide the entire class if need be - I am just in a hurry right now else I would have posted it already :)
Apr 15 '09 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

1 post views Thread by Kruq | last post: by
3 posts views Thread by Joseph D. DeJohn | last post: by
11 posts views Thread by ste | last post: by
3 posts views Thread by howardr101 | last post: by
1 post views Thread by shalini jain | last post: by
reply views Thread by George Ter-Saakov | last post: by
16 posts views Thread by gnawz | last post: by
2 posts views Thread by kkshansid | last post: by

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.