C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Resources » Articles » ASP.NET/Web Applications »

Mobile Web Development in ASP.NET - Part 4


Posted Date: 17 Mar 2006    Resource Type: Articles    Category: ASP.NET/Web Applications
Author: Balamurali BalajiMember Level: Diamond    
Rating: 1 out of 5Points: 10



Introduction



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.



<body Xmlns:mobile="http://schemas.microsoft.com/Mobile/WebForm">
<mobile:Form id="Form1" runat="server">
<mobile:ObjectList id=ObjectList1 runat="server" OnItemCommand="List1_Click" LabelField="Au_Lname" DataMember="authors" DataSource="<%# dsAuthors1 %>" LabelStyle-StyleReference="title" CommandStyle-StyleReference="subcommand" BackColor="Turquoise">
<Command Name="Titles" Text="View Titles by this Author"></Command>
<Command Name="Sales" Text="Current Sales Trend in Stores"></Command>
</mobile:ObjectList>
</mobile:Form>
<mobile:Form id="Form2" runat="server">
<mobile:ObjectList id="ObjectList2" runat="server" LabelStyle-StyleReference="title" CommandStyle-StyleReference="subcommand"
BackColor="Turquoise"></mobile:ObjectList>
</mobile:Form>
<mobile:Form id="Form3" runat="server" BackColor="Turquoise">
<mobile:Label id="Label1" runat="server" Font-Bold="True" ForeColor="Blue">Currently, this feature is not available for users!</mobile:Label>
</mobile:Form>
</body>

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.



Responses

Author: satya bhaskar mulampaka    11 May 2009Member Level: Silver   Points : 2
Hi boss,
The above information helped me a lot. but i have a problem in showing multiple rows in mobile page.. in the above demo we can only display one row... can you plz help in showing multiple row in the mobile page... i mean my select query returns multiple rows. so i have to show them as a table or grid in the mobile page.... can u please help in solving my problem...


Author: Padmini    29 Jul 2009Member Level: Bronze   Points : 2
Hi,

I am using object list control in my application. By selecting the ids from object list control, I want to navigate to results page. But on selecting id it is redirecting to one more page, from there only it is navingating to results page.
How to avoid this intermediate page?

can you plz help in solving this problem


Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Sign In to add tags.
(No tags found.)

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Mobile Web Development in ASP.NET - Part 3
Previous Resource: Mobile Web Development in ASP.NET - Part 5
Return to Discussion Resource Index
Post New Resource
Category: ASP.NET/Web Applications


Post resources and earn money!
 
More Resources



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use