LINQ and ListView problem

S

shapper

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,969
Messages
2,570,161
Members
46,708
Latest member
SherleneF1

Latest Threads

Top