ListView
Demonstriert ListView mit Pager:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
/// <summary>
/// Summary description for DataSourceData
/// </summary>
public class DataSourceData
{
public IList<int> GetDatasourceData(int maximumRows, int startRowIndex)
{
List<int> result = new List<int>();
for (int i = startRowIndex; i < maximumRows + startRowIndex; i++)
{
result.Add(i);
}
return result;
}
public int GetDatasourceDataCount()
{
return 1000;
}
}
ASPX:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="ListView.aspx.cs" Inherits="Sample_ListView" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ObjectDataSource ID="MyDataSource"
runat="server"
SelectMethod="GetDatasourceData"
TypeName="DataSourceData"
EnablePaging="True"
SelectCountMethod="GetDatasourceDataCount"/>
<asp:ListView ID="ListView1"
runat="server"
DataSourceID="MyDataSource">
<ItemTemplate>
<%# Container.DataItem %><br />
</ItemTemplate>
</asp:ListView>
<asp:DataPager runat="server" ID="BeforeListDataPager"
PagedControlID="ListView1"
PageSize="10">
<Fields>
<asp:NextPreviousPagerField
NextPageText="Ältere News"
PreviousPageText="Neuere News"
FirstPageText="Neuste News"
ShowFirstPageButton="true"/>
</Fields>
</asp:DataPager>
</div>
</form>
</body>
</html>