Steven -
I need a little more help here. You suggested the ObjectList control for
displaying lists in Mobile ASP.NET. But I'm having a little trouble
understanding how to use it. Here's the situation:
I have a class which contains a List collection. That List collection is a
list of objects of class "Picture" which. In other words, I have a List
object of Picture Objects. Each Picture object has fields for things like
Picture URL, Title, and soem Booleans.
So my questions are:
1. How do I use the ObjectList control to bind to my own List collection
instead of to a DataTable or DataSet?
2. How do I customize what is presented in each "row" with a template of my
choosing?
Thanks!
Alex
> Hi Alex,
>
[quoted text clipped - 58 lines]
>
> This posting is provided "AS IS" with no warranties, and confers no rights.
Steven Cheng[MSFT] - 15 Aug 2007 06:11 GMT
Hi Alex,
Thanks for your followup.
Regarding on the further questions you mentioned, I think you can do it as
below:
** To bind to your custom class's collection, you can simply use the
ObjectList's DataSource property and DataBind method e.g.
===================
public partial class _Default : System.Web.UI.MobileControls.MobilePage
{
protected void Page_Load(object sender, EventArgs e)
{
BindList1();
}
protected void BindList1()
{
ItemClass[] items = new ItemClass[3];
for (int i = 1; i <= 3; i++)
{
ItemClass item = new ItemClass(i, "item" + i,
"http://www.asp.net/App_Themes/Standard/i/logo.png");
items[i - 1] = item;
}
ObjectList1.DataSource = items;
ObjectList1.DataBind();
}
.........
=============================
For the define customizing template, you need to use <DeviceSpecific>
setting and you can supply mutiple <choice> segment for different device
setting e.g.
==================
<mobile:ObjectList ID="ObjectList1" Runat="server"
CommandStyle-StyleReference="subcommand" AutoGenerateFields="False"
LabelStyle-StyleReference="title"
>
<DeviceSpecific >
<Choice Filter="IsIE">
<ItemDetailsTemplate>
<br /><asp:Label ID="Label1" runat="server" Text='<%#
Eval("ID") %>'></asp:Label>
<asp:Label ID="Label3" runat="server" Text='<%# Eval("Name")
%>'></asp:Label>
<asp:Image ID="Image1" runat="server" ImageUrl='<%#
Eval("Logo") %>' />
<asp:Button ID="Button1" runat="server" Text="Choose" />
</ItemDetailsTemplate>
</Choice>
<Choice Filter="IsNotIE">
<ItemDetailsTemplate>
<mobile:Label ID="Label4" Runat="server"><%# Eval("ID")
%></mobile:Label>
<mobile:Label ID="Label2" Runat="server"><%# Eval("Name")
%></mobile:Label>
<mobile:Image ID="Image2" Runat="server"
ImageUrl="http://www.asp.net/App_Themes/Standard/i/logo.png"></mobile:Image>
</ItemDetailsTemplate>
</Choice>
</DeviceSpecific>
</mobile:ObjectList>
===========================
In the above template, one template is using HTML (standard ASP.NET
controls) and another is using mobile controls.
For the configuration and usage of DeviceFilters, you can refer to the MSDN
document or some web articles:
#Using Device Filters
https://msdn2.microsoft.com/en-us/library/d7k7a6z2.aspx
#<deviceFilters>
http://msdn2.microsoft.com/en-us/library/k25f323z.aspx
#<Choice> Element (.NET Framework Developer's Guide )
http://msdn2.microsoft.com/en-us/library/3tfbhf6f.aspx
Hope this helps.
Sincerely,
Steven Cheng
Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.