mam takovy "mensi" problem. Pouzivam listview(itemtemplate) pro vytvoreni newsek na hlavni strance. Vse funguje jak ma. Problem ale nastava, kdyz potrebuju pridat pager.
Vyhodi mi to error:
Kód: Vybrat vše
ListView with id 'articlesListView' must have a data source that either implements ICollection or can perform data source paging if AllowPaging is true.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidOperationException: ListView with id 'articlesListView' must have a data source that either implements ICollection or can perform data source paging if AllowPaging is true.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.Kod:
Kód: Vybrat vše
<asp:ListView runat="server" ID="articlesListView" DataSourceID="SqlDataSource1">
<LayoutTemplate>
<asp:PlaceHolder ID="itemPlaceHolder" runat="server"></asp:PlaceHolder>
</LayoutTemplate>
<ItemTemplate>
<div class="article">
<div class="article-headline">
<b><asp:Label ID="nameOfArticle" runat="Server" Text='<%# Eval("name") %>' CssClass="article-headline-text"/></b><br />
</div>
<div class="article-content">
<asp:Label ID="contentOfArticle" runat="Server" Text='<%# Eval("content").ToString().Substring(0, Math.Min(Eval("content").ToString().Length, 300)) + "..." %>' CssClass="article-content-text"/><br/><br/>
</div>
<div class="article-info">
<asp:Label ID="dateOfCreation" runat="Server" Text='<%# Eval("date", "{0:d}") %>' CssClass="article-info-text"/><br/><br/>
<asp:Label ID="author" runat="server" Text='<%# Eval("author") %>' CssClass="article-info-text"/><br/><br/>
<b><asp:HyperLink ID="sendIdForArticle" runat="server" Text="Číst vše" NavigateUrl='<%#"Article.aspx?id=" + Eval("id") %>' CssClass="article-info-link" /></b><br/>
</div>
</div>
</ItemTemplate>
</asp:ListView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" DataSourceMode="DataReader"
ConnectionString="<%$ ConnectionStrings:DataServices%>" SelectCommand="SELECT id, name, content, date, author, tags, is_published, section_id, category_id, is_deleted FROM articles WHERE [is_deleted]=0 AND is_published=1 ORDER BY date DESC">
</asp:SqlDataSource>
<asp:DataPager ID="DataPagerProducts" runat="server" PagedControlID="articlesListView"
PageSize="3" >
<Fields>
<asp:NextPreviousPagerField ShowFirstPageButton="True"
ShowNextPageButton="true"
ShowLastPageButton="True"
ShowPreviousPageButton="true" />
</Fields>
</asp:DataPager>
