By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,369 Members | 1,207 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,369 IT Pros & Developers. It's quick & easy.

Pagination User Control + Class problems (C#)

markrawlingson
Expert 100+
P: 346
Hello,

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!

Sincerely,
Mark
Apr 15 '09 #1
Share this Question
Share on Google+
1 Reply


markrawlingson
Expert 100+
P: 346
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.