Mobile "Repeater"

G

Guest

Hi. I'm trying to figure out how you do the most basic Data-Bound "Repeater"
functionality on a Mobile ASPX page. I don't mean a list box, because it will
have repeated HTML and User Controls in each Row. How do I do this, please?

Thanks!

Alex
 
S

Steven Cheng[MSFT]

Hi Alex,

For standard web page's "Repeater" like functionality, in ASP.NET Mobile
application, there are two common approaches:

1) you can have a look at the "ObjectList" control, this is the template
databound control in ASP.NET Mobile's standard control collection:

#Introduction to the ObjectList Control
http://msdn2.microsoft.com/en-us/library/d7hb3s0f.aspx

#Using Data Binding with ASP.NET Mobile Controls
http://msdn2.microsoft.com/en-us/library/8yc44h4d.aspx


2) As we've discussed in some previous methods. Using DeviceSpecific
template is always an options for those HTML/XHTML suppoted device, and you
can define and use standard ASP.NET controls(datalist or repeater) in those
specific template:

#Template Sets and Templated Controls
http://msdn2.microsoft.com/en-us/library/39dfzhdc.aspx

#How to: Create and Edit Templates
http://msdn2.microsoft.com/en-us/library/6c1x9zwd.aspx

#Customizing ASP.NET Mobile Web Controls for Specific Devices
http://msdn2.microsoft.com/en-us/library/0ffa7b0h.aspx

Hope this helps.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead



==================================================

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.



Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.

==================================================


This posting is provided "AS IS" with no warranties, and confers no rights.
 
G

Guest

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
 
S

Steven Cheng[MSFT]

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,773
Messages
2,569,594
Members
45,119
Latest member
IrmaNorcro
Top