Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / August 2007

Tip: Looking for answers? Try searching our database.

Mobile "Repeater"

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Alex Maghen - 06 Aug 2007 19:58 GMT
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
Steven Cheng[MSFT] - 07 Aug 2007 04:43 GMT
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.
Alex Maghen - 14 Aug 2007 21:10 GMT
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.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.