Share via


LoadItems Event

Occurs when a control is custom-paginated and needs more data.

public event LoadItemsEventHandler LoadItems

Remarks

When control is custom-paginated, you do not explicitly bind the control. After pagination, the control raises this event, indicating what part of the data is required. The application can handle this event and bind the control with the required data.

Example

The following example demonstrates how to trap the LoadItems event for a paginated List control, where the user can specify how many items to show on the page.

[Visual Basic]

<Script language="vb" runat="server">

Sub loadNow(sender As Object, e As LoadItemsEventArgs)
   
   CType(myForm.Header.FindControl("label1"), System.Web.UI.MobileControls.Label).Text = "Maximum Item Allowed In " + "page is " + e.ItemCount.ToString()
   list1.Items.Clear()
   Dim arr As New ArrayList()
   
   ' Display items.
   Dim i As Integer
   For i = 0 To e.ItemCount
      arr.Add(e.ItemIndex)
   Next i
   list1.DataSource = arr
   list1.DataBind()

End Sub

<Mobile:Form runat=server id=myForm Paginate=true>
  <DeviceSpecific>
   <Choice>
      <HeaderTemplate>
         <Mobile:Label runat=server id=label1 
            StyleReference="title" />
      </HeaderTemplate>
   </Choice>
  </DeviceSpecific>
  <Mobile:List id="list1" runat=server ItemCount=2000
     onLoadItems ="loadNow"/>
</Mobile:Form>
</Script>
<script language="c#" runat="server">
void loadNow(object sender, LoadItemsEventArgs e)
{

   ((System.Web.UI.MobileControls.Label)myForm.Header.
      FindControl("label1")).Text = "Maximum Item Allowed In" +
      "page is " + e.ItemCount.ToString();
   list1.Items.Clear();
   ArrayList arr= new ArrayList();

   // Display items.
   for(int i = 0; i <= (e.ItemCount); i++)
   {
      arr.Add(e.ItemIndex);
   }
   list1.DataSource=arr;
   list1.DataBind();
}

</script>

<Mobile:Form runat=server id=myForm Paginate=true>
  <DeviceSpecific>
   <Choice>
      <HeaderTemplate>
         <Mobile:Label runat=server id=label1 
            StyleReference="title" />
      </HeaderTemplate>
   </Choice>
  </DeviceSpecific>
  <Mobile:List id="list1" runat=server ItemCount=2000
     onLoadItems ="loadNow"/>
</Mobile:Form>

See Also

PagedControl Class