Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / December 2007

Tip: Looking for answers? Try searching our database.

LINQ and ListView problem

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
shapper - 13 Dec 2007 21:54 GMT
Hello,

I have a ListView where I use LINQ for data, for example, selecting,
and deleting.
In the ListView item template I added a DataPager.

When I click, for example, "Next Page" or a page number in the
DataPager something strange happens:
It always takes me 2 clicks for the action to be taken.

The only thing that solves this is to move the code I have in my
ListView Load event to the ListView PreRender event.

Please, does anyone has any idea what I am doing wrong?

Here is my ListView code:

   Private Sub lvTags_Init(ByVal sender As Object, ByVal e As
EventArgs) Handles lvTags.Init
     lvTags.DataKeyNames = New String() {"TagID"}
     lvTags.ID = "lvTags"
     lvTags.ItemTemplate = New
TagsTemplate(TemplateType.ItemTemplate)
     lvTags.LayoutTemplate = New
TagsTemplate(TemplateType.LayoutTemplate)
   End Sub
   Private Sub lvTags_Load(ByVal sender As Object, ByVal e As
EventArgs) Handles lvTags.Load
     Dim database As New CodeDataContext
     Dim tags = From t In database.Tags Select t.TagID, t.Text
     lvTags.DataSource = tags
     lvTags.DataBind()
   End Sub ' lvTags_Load

And my DataPager code which I add inside the ListView ItemTemplate
implementation is:

   Private Sub dpTags_Init(ByVal sender As Object, ByVal e As
EventArgs)

     Dim dpTags As DataPager = CType(sender, DataPager)

     Dim field As New NextPreviousPagerField
     field.FirstPageText = "<<"
     field.PreviousPageText = "<"
     field.NextPageText = ">"
     field.LastPageText = ">>"

     dpTags.ID = "dpTags"
     dpTags.PageSize = 8
     dpTags.Fields.Add(field)

   End Sub ' dpTags_Init

Thanks,
Miguel
David Wier - 13 Dec 2007 22:24 GMT
Try moving the Datapager outside the Listview ItemTemplate. You should be
able to put it anywhere on the page, and set the PagedControlID to your
ListView

David Wier
http://aspnet101.com
http://iWritePro.com - One click PDF, convert .doc/.rtf/.txt to HTML with no
bloated markup

> Hello,
>
[quoted text clipped - 52 lines]
> Thanks,
> Miguel

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.