Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > LINQ and ListView problem

Reply
Thread Tools

LINQ and ListView problem

 
 
shapper
Guest
Posts: n/a
 
      12-13-2007
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
 
Reply With Quote
 
 
 
 
David Wier
Guest
Posts: n/a
 
      12-13-2007
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


"shapper" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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



 
Reply With Quote
 
 
 
Reply

Thread Tools

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
asp.net ListView control - Configure ListView option missing? . ASP .Net 0 07-24-2010 12:20 AM
Linq or not Linq George ASP .Net 4 11-05-2008 04:53 PM
Finding and selecting a record in a gridview with paging and sortingenabled (using LINQ) Mike N. ASP .Net 0 07-31-2008 04:55 PM
Finding and selecting a record in a gridview with paging and sortingenabled (using LINQ) Mike N. ASP .Net 0 07-31-2008 04:47 PM
Linq.Binary vs. LinqDatasource vs. ListView Rasmus ASP .Net 0 12-12-2007 08:11 AM



Advertisments