ObjectListDataBindEventArgs Class
Provides data for the ItemDataBind event of an ObjectList control.
public class System.Web.UI.MobileControls.ObjectListDataBindEventArgs :
System.Object.EventArgs
Remarks
An inherited class or event handler can use the ItemDataBind event to perform complex data binding.
Example
In this example, the ItemdataBind event calls the user-defined function confirmBound
. This function has ObjectListDataBindEventArgs
as one of its arguments. This argument is cast as a book type, thus gaining access to its properties, such as the book name and the author.
<%@ Page Inherits="System.Web.UI.MobileControls.MobilePage"
Language="c#" %>
<script Language="c#" runat="server">
class Book
{
private String _BookName, _Author, _InStock;
public Book(String BookName, String Author, String InStock)
{
_BookName = BookName;
_Author = Author;
_InStock = InStock;
}
public String BookName { get { return _BookName; } }
public String Author { get { return _Author; } }
public String InStock { get { return _InStock; } }
}
public void Page_Load(Object sender, EventArgs e)
{
// Create and fill array.
ArrayList arr = new ArrayList();
arr.Add (new Book ("Sushi, Anyone?", "O'Leary", "Yes"));
arr.Add (new Book ("Secrets of Silicon Valley", "Dull", "No"));
arr.Add (new Book ("Net Etiquette", "Locksley", "Yes"));
arr.Add (new Book ("The Gourmet Microwave", "Ringer", "No"));
// Associate and bind the array to the ObjectList object.
ObjectList1.DataSource = arr;
ObjectList1.DataBind ();
// Override autogeneration.
ObjectList1.LabelField = "BookName";
}
void confirmBound(object sender, ObjectListDataBindEventArgs e)
{
// The event has been raised at time of data binding.
Label1.Text = "Data bound to an ObjectList object.";
// Use the ListItem property of the ObjectListDataBindEventArgs class
// to return the book's name.
Label2.Text = "Book Name: " +
e.ListItem["BookName"];
// You can access the same item through the DataItem property of the
// ObjectListDataBindEventArgs class.
Label3.Text = "Author : " + ((Book)(e.DataItem)).Author;
}
</script>
<mobile:Form runat="server" id="Form1" >
<mobile:ObjectList runat="server" id="ObjectList1"
OnItemDataBind="confirmBound" >
</mobile:ObjectList>
<mobile:Label runat="server" id="Label1" />
<mobile:Label runat="server" id="Label2" />
<mobile:Label runat="server" id="Label3" />
</mobile:Form>
Requirements
Namespace: System.Web.UI.MobileControls
Assembly: System.Web.Mobile