PagedControl.LoadItems 事件
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
控制項已自訂分頁且需要更多資料時會發生。 這個 API 已經過時。 如需如何開發 ASP.NET 行動應用程式的資訊,請參閱 具有 ASP.NET 的Mobile Apps & Sites。
public:
event System::Web::UI::MobileControls::LoadItemsEventHandler ^ LoadItems;
public event System.Web.UI.MobileControls.LoadItemsEventHandler LoadItems;
member this.LoadItems : System.Web.UI.MobileControls.LoadItemsEventHandler
Public Custom Event LoadItems As LoadItemsEventHandler
事件類型
範例
下列範例示範如何使用 ItemsPerPage 屬性來呈現每個頁面 200 個項目清單的八個專案。
<%@ Page Language="C#"
Inherits="System.Web.UI.MobileControls.MobilePage" %>
<%@ Register TagPrefix="mobile"
Namespace="System.Web.UI.MobileControls"
Assembly="System.Web.Mobile" %>
<script runat="server">
// Called by the List whenever it needs new items
private void LoadNow(object sender, LoadItemsEventArgs e)
{
int j = e.ItemIndex;
int estItemSize = 110;
// Get the optimum page weight for the device
int wt = Form1.Adapter.Page.Adapter.OptimumPageWeight;
// Get the number of items per page
List1.ItemsPerPage = wt / estItemSize;
// Clear the current items
List1.Items.Clear();
// Build a section of the array
ArrayList arr= new ArrayList();
for (int i = 1; i <= e.ItemCount; i++)
{
int v = i + j;
arr.Add((v.ToString() + " List Item"));
}
// Assign the array to the list
List1.DataSource = arr;
List1.DataBind();
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<body>
<mobile:Form id="Form1" runat="server" Paginate="true">
<mobile:List id="List1" runat="server"
ItemCount="200" onLoadItems="LoadNow" />
</mobile:Form>
</body>
</html>
<%@ Page Language="VB"
Inherits="System.Web.UI.MobileControls.MobilePage" %>
<%@ Register TagPrefix="mobile"
Namespace="System.Web.UI.MobileControls"
Assembly="System.Web.Mobile" %>
<script runat="server">
' Called by the List whenever it needs new items
Private Sub LoadNow(ByVal sender As Object, _
ByVal e As LoadItemsEventArgs)
Dim i, j As Integer
i = 0
j = e.ItemIndex
Dim estItemSize As Integer = 110
' Get the optimum page weight for the device
Dim wt As Integer = _
form1.Adapter.Page.Adapter.OptimumPageWeight
' Get the number of items per page
List1.ItemsPerPage = wt / estItemSize
' Clear the current items
List1.Items.Clear()
' Build a section of the array
Dim arr As New ArrayList()
For i = 1 To e.ItemCount
arr.Add(j + i)
Next
' Assign the array to the list
List1.DataSource = arr
List1.DataBind()
End Sub
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<body>
<mobile:form id="form1" runat="server" Paginate="true">
<mobile:List id="List1" runat="server"
ItemCount="200" onLoadItems="LoadNow"
ItemsPerPage="8" />
</mobile:form>
</body>
</html>
備註
當控件是自定義編頁時,您不會明確系結控件。 分頁之後,控件會引發這個事件,指出需要哪些部分的數據。 應用程式可以處理此事件,並將控件與必要的數據系結。