Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

LINQ and paging with a listview

I have a page with a listview control and a datapager control. The listviews datasource is set programatically using this code:

Dim dal as new dalDataContext
Dim bookmarks = From data In dal.getData(userid)
listview1.DataSource = bookmarks
listview1.DataBind()

When i test this page in a browser it comes up with the error: 'ListView with id 'listview1' must have a data source that either implements ICollection or can perform data source paging if AllowPaging is true.'

How can i implement paging in this scenario?

Thanks

like image 943
j82374823749 Avatar asked Jul 30 '09 16:07

j82374823749


2 Answers

Try

listview1.DataSource = bookmarks.ToArray()

I had the same problem this week.

like image 87
KClough Avatar answered Sep 20 '22 17:09

KClough


An answer to the click-twice problem that the OP subsequently encountered - move the Databind to the OnPreRender event handler:

    protected void Page_PreRender(object sender, EventArgs e)
    {
        listview1.DataBind();
    }
like image 31
CJM Avatar answered Sep 18 '22 17:09

CJM