Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Search | Today's Posts | Mark Forums Read
BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3
This is the forum to discuss the Wrox book Beginning ASP.NET 3.5: In C# and VB by Imar Spaanjaars; ISBN: 9780470187593
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 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
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old May 31st, 2010, 02:33 PM
Authorized User
 
Join Date: Sep 2009
Posts: 35
Thanks: 6
Thanked 1 Time in 1 Post
Default datapager for programatic listview

Hey Imar,

I was searching through your book to see if I could find a solution to this, but I didn't seem to find it in there hopefully you can help me.

I am setting the datasource of my list view programatically (in the code behind), and due to this the datapager I am trying to use doesn't seem to be working as it would in the book (when you assign the datasource of the listview via the menus within visual web developer). The buttons do appear but they do nothing but just refresh the page (cause a post back).

Do you have any idea on what I could do here?

Thanks

When I try to just throw a datapager onto the page and assign it to the Listview I'm defining in the code I get this error:

Code:
Invalid postback or callback argument.  Event validation is enabled using <pages enableEventValidation="true"/> in configuration or <%@ Page EnableEventValidation="true" %> in a page.  For security purposes, this feature verifies that arguments to postback or callback events originate from the server control that originally rendered them.  If the data is valid and expected, use the ClientScriptManager.RegisterForEventValidation method in order to register the postback or callback data for validation.

Last edited by digink; May 31st, 2010 at 02:40 PM..
Reply With Quote
  #2 (permalink)  
Old May 31st, 2010, 03:27 PM
Imar's Avatar
Wrox Author
Points: 72,073, Level: 100
Points: 72,073, Level: 100 Points: 72,073, Level: 100 Points: 72,073, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Have you tried wrapping the assignment of your data in a !PostBack block? E.g.

Code:
 
if (!Page.IsPostBack)
{
  // get data here
  myControl.DataSource = yourData;
  myControl.DataBind();
}
Hope this helps,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
Reply With Quote
  #3 (permalink)  
Old May 31st, 2010, 04:06 PM
Authorized User
 
Join Date: Sep 2009
Posts: 35
Thanks: 6
Thanked 1 Time in 1 Post
Default

Quote:
Originally Posted by Imar View Post
Have you tried wrapping the assignment of your data in a !PostBack block? E.g.

Code:
 
if (!Page.IsPostBack)
{
  // get data here
  myControl.DataSource = yourData;
  myControl.DataBind();
}
Hope this helps,

Imar
I tried that but it still causes some strange behavior, like the first time NEXT is clicked nothing happens to the data, but after that it displays the second page. And I am never able to come back to the previous page.

Do you have any idea if there is any other controls I can use? I kind of want to do something where I dont need a datapager but maybe some sort of java that just has a scroll type feature? That way I can just have all the data loaded on page_load like i'm doing now and use some sort of AJAX to have a scroller.
Reply With Quote
  #4 (permalink)  
Old May 31st, 2010, 04:21 PM
Imar's Avatar
Wrox Author
Points: 72,073, Level: 100
Points: 72,073, Level: 100 Points: 72,073, Level: 100 Points: 72,073, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

You may want to take a look here:

http://www.4guysfromrolla.com/articles/021308-1.aspx
http://www.codedigest.com/Articles/A...ASPNet_35.aspx
http://www.google.com/#hl=en&source=...+paging+custom

Cheers,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
Reply With Quote
The Following User Says Thank You to Imar For This Useful Post:
digink (May 31st, 2010)
  #5 (permalink)  
Old May 31st, 2010, 04:49 PM
Authorized User
 
Join Date: Sep 2009
Posts: 35
Thanks: 6
Thanked 1 Time in 1 Post
Default

I got it to work Imar, thanks again for the suggestions.

Incase you're curious, I had to add the same data definition for the list view to the ListView1_PagePropertiesChanged event and it is working beautifully.

Thanks again!
Reply With Quote
  #6 (permalink)  
Old June 1st, 2010, 02:07 AM
Imar's Avatar
Wrox Author
Points: 72,073, Level: 100
Points: 72,073, Level: 100 Points: 72,073, Level: 100 Points: 72,073, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Excellent. Thanks for the follow up...

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
Reply With Quote
Reply


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
Datapager in Listview monika.vasvani ASP.NET 3.5 Professionals 0 March 10th, 2010 05:45 AM
Datapager in Listview monika.vasvani ASP.NET 3.5 Professionals 0 March 9th, 2010 09:31 AM
DataPager & PlaceHolder positions jsymons BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 3 September 25th, 2009 07:50 AM
ListView fredforfree ASP.NET 2.0 Basics 1 August 1st, 2009 03:01 PM
Programatic word merge fizzerchris Access VBA 3 September 20th, 2007 09:12 PM



All times are GMT -4. The time now is 06:18 AM.


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