The Part4 of the series on Mobile Web Development deals with the ObjectList control that offers you ways of listing data objects from data source or any other collection of items from an array or arraylist.
ObjectList Control
It provides a feature-rich view of a list of data objects. The ObjectList control inherits much of its behavior, including support for templated rendering by using device template sets, and internal pagination, from the List control. Although they are both lists, a ObjectList control differs in capabilities and scope from a List control.
Features of ObjectList control
Data bound
ObjectList control is strictly data bound. The only way to add items to an object list in a control is by binding the list to a data source.
Multiple-property view
It allows you to view multiple properties, or fields, associated with each item. Depending on device characteristics, the control can be rendered as a table that displays more than one property of each object, or UI can be provided to allow the user to view additional properties of an object.
Multiple item commands
It allows you to associate multiple commands with each item. The set of commands for an item can be either shared among all items or unique to the item.
Internal pagination and templating
is supported.
The following controls can contain one or more ObjectList controls.
System.Web.UI.MobileControls.Form
System.Web.UI.MobileControls.Panel
The ObjectList control can contain one or more of the following control.
System.Web.UI.MobileControls.ObjectList.Field
System.Web.UI.MobileControls.ObjectList.Command
Device Templates
The ObjectList control support the following device templates.
AlternatingItemTemplate
This template renders even-numbered items in a list view of an ObjectList object.
HeaderTemplate
The header template is rendered at the beginning of the list. In paginated mode, the header is rendered on each page.
FooterTemplate
The footer template is rendered at the end of the list. In paginated mode, the footer is rendered on each page.
ItemDetailsTemplate
This template replaces the rendering of the commands/details view for an ObjectList object.
ItemTemplate
The item template is rendered for each list item.
SeparatorTemplate
The separator template separates items from each other.
Device-Specific Behavior – HTML
On HTML devices, the object list is initially rendered as a table, with each list item (object) represented by a link. The default value for the link is a value associated with the first column in the dataset. You can set any column as a LabelField Property.
Device-Specific Behavior – WML
On WML devices, the object list is initially rendered as a select list, with each item represented by its label. By selecting the item, the user can view a menu of commands for the item, including a link labeled "Details". By clicking "Details", the user can view title and value of all fields.
Example6
The following example shows how to use Object list for viewing titles by author. It is bound to the dataset “dsAuthors”. The page has three mobile form controls and on the mobile form 1, ObjectList shows a list of all authors. On selecting a command to view the titles by author, mobile form 2 is activated where in user could see the list of titles. On selecting the Sales Trend Link, mobile form 3 is activated that displays a message.
private void Page_Load(object sender, System.EventArgs e)
{
if (Page.IsPostBack == false)
{
oleDbDataAdapter1.Fill(dsAuthors1);
ObjectList1.DataBind();
}
}
string authorid;
public void List1_Click(Object sender, ObjectListCommandEventArgs e)
{
authorid = e.ListItem[0];
if (e.CommandName == "Titles")
{
ActiveForm = Form2;
}
else if (e.CommandName == "Sales")
{
ActiveForm = Form3;
}
else
{
ActiveForm = Form1;
}
private void GetAuthorTitles()
{
string ssql = "select titles.title_id, title, type, price, notes from titleauthor, titles where titleauthor.au_id = '" + authorid + "' and titleauthor.title_id = titles.title_id";
DataSet ds1 = new DataSet();
OleDbDataAdapter Adapter = new OleDbDataAdapter(ssql,oleDbConnection1);
Adapter.Fill(ds1);
ObjectList2.DataSource = ds1;
ObjectList2.LabelField = "Title";
ObjectList2.DataBind();
}
private void Form2_Activate(object sender, System.EventArgs e)
{
GetAuthorTitles();
}
Summary
This part covered the most significant use of ObjectList control. The next part of the article would discuss about simple controls like PhoneCall, Link and TextView.
Regard
Prateek
Thanks for sharing your valuable knowledge about web development services
ReplyDeleteMost website developers make sure that the image composition of the website is such that it loads at a faster rate.
Web Development Indian
Great Article
ReplyDeleteCASP.NET Online Training | C# Online Training
ASP.NET Training In Chennai | C# Training in Chennai