ObjectList Data-Binding to a List<MyClass>

Discussion in 'ASP .Net' started by =?Utf-8?B?QWxleCBNYWdoZW4=?=, Aug 17, 2007.

  1. Let's say I have defined a class:

    public class TestClass
    {
    int m_ID;
    string m_UserTitle;

    public TestClass(int ID, string UserTitle)
    {
    m_ID = ID;
    m_UserTitle = UserTitle;
    }

    public int ID
    {
    get
    {
    return (m_ID);
    }
    }
    public string UserTitle
    {
    get
    {
    return (m_UserTitle);
    }
    }
    }


    Now I want to display it using an ObjectList, so I do this on my ASPX page...

    <mobile:ObjectList ID="OL" Runat="server"
    CommandStyle-StyleReference="subcommand" AutoGenerateFields="False"
    LabelStyle-StyleReference="title">
    <DeviceSpecific>
    <Choice>
    <ItemDetailsTemplate>
    <mobile:Label ID="Label4" Runat="server"><%# Eval("ID")
    %></mobile:Label>
    <mobile:Label ID="Label2" Runat="server"><%#
    Eval("UserTitle") %></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>


    NOW, back in my page code, I do this...

    private void DisplayList()
    {

    List<TestClass> L = new List<TestClass>();

    L.Add(new TestClass(1, "UserTitle 1"));
    L.Add(new TestClass(2, "UserTitle 2"));

    OL.DataSource = L;
    OL.DataBind(); //RUNTIME ERROR HAPPENS HERE!
    }

    Note that I am trying to configure this control to only have one template
    which will be very VERY simple and should work for all devices.

    When I have done all this, I get a runtime error on the DataBind() line as
    follows...

    System.Exception was unhandled by user code
    Message="Must have one or more fields to databind.
    (Application may have autogenerated fields from an empty DataSource. To
    clear items, set DataSource to null.)"


    Any ideas what I'm doign wrong here?

    Thanks!

    Alex
     
    =?Utf-8?B?QWxleCBNYWdoZW4=?=, Aug 17, 2007
    #1
    1. Advertising

  2. Hi Alex,

    Seems this is a continual post from a former thread discussing on "Mobile
    Repeater", correct?

    I've performed test through the code you provided and did met the error you
    said. After some research, I found that the error is caused by no data
    fields are defined in the ObjectList control. Actually, if you turn off
    "AutoGenerateFields" in ObjectList, you need to supply the fields you want
    to use in your ObjectList. You should use the <Field > element to add
    fields definition into the ObjectList.

    For your "TestClass" scenario, here is the expected ObjectList aspx
    template:

    ================
    <mobile:ObjectList ID="ObjectList1" Runat="server"
    CommandStyle-StyleReference="subcommand"
    LabelStyle-StyleReference="title" AutoGenerateFields="False"
    LabelField="UserTitle" >

    <DeviceSpecific ID="ds_ol1" Runat="server">

    <Choice >



    <ItemDetailsTemplate>
    detail template:
    <mobile:Label ID="Label1" Runat="server"><%# Eval("ID")
    %></mobile:Label>
    <mobile:Label ID="Label2" Runat="server"><%# Eval("UserTitle")
    %></mobile:Label>

    </ItemDetailsTemplate>

    </Choice>

    </DeviceSpecific>


    <Field Title="ID" DataField="ID" />
    <Field Title="UserTitle" DataField="UserTitle" />
    </mobile:ObjectList>
    ========================

    Also, I found a good web forum thread which has included some advanced
    setting and usage upon ObjectList control, you can also have a look if you
    need some further customzation or event handling:

    http://forums.asp.net/p/1146753/1862202.aspx

    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.
     
    Steven Cheng[MSFT], Aug 20, 2007
    #2
    1. Advertising

  3. Steven -

    Thanks for getting back to me about all these posts. I have been away and am
    just getting back to it now. I must say, I find this entire approach
    *incredibly* complicated for something as simple as providing a listing of
    objects/assets from a List or Database table. But there's nothing I can do
    about it, I guess so I have to keep bothering you until I really understand.
    I implemented exactly what you defined below and I'm no longer getting the
    error I was getting before, but I *am* still having a problem:

    In the <ItemDetailsTemplate> section (below), I've presented two
    <mobile:Label ...> objects, one whose content is set to: <%# Eval("ID") %>
    and another whose content is set to <%# Eval("UserTitle") %>. I then also
    added the two <Field...> tags for ID and UserTitle below (just as you
    defined). When I run this, though, all I see is a "table" with a single
    column showing the "ID" header and "ID" entries only. The second label for
    the "UserTitle" is simply not shown. Also, in your sample, you placed the
    text "detail template:" just inside the <ItemDetailsTemplate> tag. This is
    literal text and I would have assumed that it would just show up in every
    row. Instead, it doesn't show up at all.

    Can you please help? This is an incredibly complicated way of doing
    something really simple - or so it seems.

    Thanks as always.

    Alex



    "Steven Cheng[MSFT]" wrote:

    > Hi Alex,
    >
    > Seems this is a continual post from a former thread discussing on "Mobile
    > Repeater", correct?
    >
    > I've performed test through the code you provided and did met the error you
    > said. After some research, I found that the error is caused by no data
    > fields are defined in the ObjectList control. Actually, if you turn off
    > "AutoGenerateFields" in ObjectList, you need to supply the fields you want
    > to use in your ObjectList. You should use the <Field > element to add
    > fields definition into the ObjectList.
    >
    > For your "TestClass" scenario, here is the expected ObjectList aspx
    > template:
    >
    > ================
    > <mobile:ObjectList ID="ObjectList1" Runat="server"
    > CommandStyle-StyleReference="subcommand"
    > LabelStyle-StyleReference="title" AutoGenerateFields="False"
    > LabelField="UserTitle" >
    >
    > <DeviceSpecific ID="ds_ol1" Runat="server">
    >
    > <Choice >
    >
    >
    >
    > <ItemDetailsTemplate>
    > detail template:
    > <mobile:Label ID="Label1" Runat="server"><%# Eval("ID")
    > %></mobile:Label>
    > <mobile:Label ID="Label2" Runat="server"><%# Eval("UserTitle")
    > %></mobile:Label>
    >
    > </ItemDetailsTemplate>
    >
    > </Choice>
    >
    > </DeviceSpecific>
    >
    >
    > <Field Title="ID" DataField="ID" />
    > <Field Title="UserTitle" DataField="UserTitle" />
    > </mobile:ObjectList>
    > ========================
    >
    > Also, I found a good web forum thread which has included some advanced
    > setting and usage upon ObjectList control, you can also have a look if you
    > need some further customzation or event handling:
    >
    > http://forums.asp.net/p/1146753/1862202.aspx
    >
    > 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.
    >
    >
    >
     
    =?Utf-8?B?QWxleCBNYWdoZW4=?=, Aug 31, 2007
    #3
  4. Steven -

    One more note: I have successfully gotton it to show both columns by adding
    TableFields="ID;UserTitle"
    to the <mobile:ObjectList...> tag. But I still can't get it to display
    standard text of mark-up that I have placed in the <ItemDetailsTemplate>. It
    just ignores that and only displays the <mobile: Label...> objects that I
    have bound to my data fields. What is *with* this control?! Why is it so
    constrained? All I want is a control that allows me to manually build HTML
    markup for each object in a list (whether a database DataTable or some other
    kind of list). I have that *so* easily with the Repeater control in standard
    ASPX which allows me to repeat *anyuthing* over and over again based on rows
    from a List. What that markup is that is sent to the browser is up to me and
    if I include items that the browser can't handle, that's *my* problem. Why
    can't I do that in mobile. Sorry, but this is incredibly frustrating for
    something so simple.

    As always, thanks!

    Alex

    "Alex Maghen" wrote:

    > Steven -
    >
    > Thanks for getting back to me about all these posts. I have been away and am
    > just getting back to it now. I must say, I find this entire approach
    > *incredibly* complicated for something as simple as providing a listing of
    > objects/assets from a List or Database table. But there's nothing I can do
    > about it, I guess so I have to keep bothering you until I really understand.
    > I implemented exactly what you defined below and I'm no longer getting the
    > error I was getting before, but I *am* still having a problem:
    >
    > In the <ItemDetailsTemplate> section (below), I've presented two
    > <mobile:Label ...> objects, one whose content is set to: <%# Eval("ID") %>
    > and another whose content is set to <%# Eval("UserTitle") %>. I then also
    > added the two <Field...> tags for ID and UserTitle below (just as you
    > defined). When I run this, though, all I see is a "table" with a single
    > column showing the "ID" header and "ID" entries only. The second label for
    > the "UserTitle" is simply not shown. Also, in your sample, you placed the
    > text "detail template:" just inside the <ItemDetailsTemplate> tag. This is
    > literal text and I would have assumed that it would just show up in every
    > row. Instead, it doesn't show up at all.
    >
    > Can you please help? This is an incredibly complicated way of doing
    > something really simple - or so it seems.
    >
    > Thanks as always.
    >
    > Alex
    >
    >
    >
    > "Steven Cheng[MSFT]" wrote:
    >
    > > Hi Alex,
    > >
    > > Seems this is a continual post from a former thread discussing on "Mobile
    > > Repeater", correct?
    > >
    > > I've performed test through the code you provided and did met the error you
    > > said. After some research, I found that the error is caused by no data
    > > fields are defined in the ObjectList control. Actually, if you turn off
    > > "AutoGenerateFields" in ObjectList, you need to supply the fields you want
    > > to use in your ObjectList. You should use the <Field > element to add
    > > fields definition into the ObjectList.
    > >
    > > For your "TestClass" scenario, here is the expected ObjectList aspx
    > > template:
    > >
    > > ================
    > > <mobile:ObjectList ID="ObjectList1" Runat="server"
    > > CommandStyle-StyleReference="subcommand"
    > > LabelStyle-StyleReference="title" AutoGenerateFields="False"
    > > LabelField="UserTitle" >
    > >
    > > <DeviceSpecific ID="ds_ol1" Runat="server">
    > >
    > > <Choice >
    > >
    > >
    > >
    > > <ItemDetailsTemplate>
    > > detail template:
    > > <mobile:Label ID="Label1" Runat="server"><%# Eval("ID")
    > > %></mobile:Label>
    > > <mobile:Label ID="Label2" Runat="server"><%# Eval("UserTitle")
    > > %></mobile:Label>
    > >
    > > </ItemDetailsTemplate>
    > >
    > > </Choice>
    > >
    > > </DeviceSpecific>
    > >
    > >
    > > <Field Title="ID" DataField="ID" />
    > > <Field Title="UserTitle" DataField="UserTitle" />
    > > </mobile:ObjectList>
    > > ========================
    > >
    > > Also, I found a good web forum thread which has included some advanced
    > > setting and usage upon ObjectList control, you can also have a look if you
    > > need some further customzation or event handling:
    > >
    > > http://forums.asp.net/p/1146753/1862202.aspx
    > >
    > > 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.
    > >
    > >
    > >
     
    =?Utf-8?B?QWxleCBNYWdoZW4=?=, Aug 31, 2007
    #4
  5. Thanks for your followup Alex,

    For the "ItemDetailsTemplate" template issue you mentioned, it maybe still
    due to the control use the default template since there may have any other
    setting and prevent your custom one from display. Yes, mobile control is
    not natually targeting html from its designate, so that does make us feel
    abit inconvenient when we want to author standard html/xhtml content for
    mobile page.

    BTW, as most smart devices not support html and asp.net standard
    application control also have adaptable rendering model, maybe you can
    consider use a standard aspx page here as you will mostly use html based
    content. Is this possible in your application?


    Sincerely,

    Steven Cheng

    Microsoft MSDN Online Support Lead


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


    --------------------
    >Thread-Topic: ObjectList Data-Binding to a List<MyClass>
    >Date: Fri, 31 Aug 2007 07:52:01 -0700


    >
    >Steven -
    >
    >One more note: I have successfully gotton it to show both columns by

    adding
    > TableFields="ID;UserTitle"
    >to the <mobile:ObjectList...> tag. But I still can't get it to display
    >standard text of mark-up that I have placed in the <ItemDetailsTemplate>.

    It
    >just ignores that and only displays the <mobile: Label...> objects that I
    >have bound to my data fields. What is *with* this control?! Why is it so
    >constrained? All I want is a control that allows me to manually build HTML
    >markup for each object in a list (whether a database DataTable or some

    other
    >kind of list). I have that *so* easily with the Repeater control in

    standard
    >ASPX which allows me to repeat *anyuthing* over and over again based on

    rows
    >from a List. What that markup is that is sent to the browser is up to me

    and
    >if I include items that the browser can't handle, that's *my* problem. Why
    >can't I do that in mobile. Sorry, but this is incredibly frustrating for
    >something so simple.
    >
    >As always, thanks!
    >
    >Alex
    >
    >"Alex Maghen" wrote:
    >
    >> Steven -
    >>
    >> Thanks for getting back to me about all these posts. I have been away

    and am
    >> just getting back to it now. I must say, I find this entire approach
    >> *incredibly* complicated for something as simple as providing a listing

    of
    >> objects/assets from a List or Database table. But there's nothing I can

    do
    >> about it, I guess so I have to keep bothering you until I really

    understand.
    >> I implemented exactly what you defined below and I'm no longer getting

    the
    >> error I was getting before, but I *am* still having a problem:
    >>
    >> In the <ItemDetailsTemplate> section (below), I've presented two
    >> <mobile:Label ...> objects, one whose content is set to: <%# Eval("ID")

    %>
    >> and another whose content is set to <%# Eval("UserTitle") %>. I then

    also
    >> added the two <Field...> tags for ID and UserTitle below (just as you
    >> defined). When I run this, though, all I see is a "table" with a single
    >> column showing the "ID" header and "ID" entries only. The second label

    for
    >> the "UserTitle" is simply not shown. Also, in your sample, you placed

    the
    >> text "detail template:" just inside the <ItemDetailsTemplate> tag. This

    is
    >> literal text and I would have assumed that it would just show up in

    every
    >> row. Instead, it doesn't show up at all.
    >>
    >> Can you please help? This is an incredibly complicated way of doing
    >> something really simple - or so it seems.
    >>
    >> Thanks as always.
    >>
    >> Alex
    >>
    >>
    >>
    >> "Steven Cheng[MSFT]" wrote:
    >>
    >> > Hi Alex,
    >> >
    >> > Seems this is a continual post from a former thread discussing on

    "Mobile
    >> > Repeater", correct?
    >> >
    >> > I've performed test through the code you provided and did met the

    error you
    >> > said. After some research, I found that the error is caused by no data
    >> > fields are defined in the ObjectList control. Actually, if you turn

    off
    >> > "AutoGenerateFields" in ObjectList, you need to supply the fields you

    want
    >> > to use in your ObjectList. You should use the <Field > element to add
    >> > fields definition into the ObjectList.
    >> >
    >> > For your "TestClass" scenario, here is the expected ObjectList aspx
    >> > template:
    >> >
    >> > ================
    >> > <mobile:ObjectList ID="ObjectList1" Runat="server"
    >> > CommandStyle-StyleReference="subcommand"
    >> > LabelStyle-StyleReference="title"

    AutoGenerateFields="False"
    >> > LabelField="UserTitle" >
    >> >
    >> > <DeviceSpecific ID="ds_ol1" Runat="server">
    >> >
    >> > <Choice >
    >> >
    >> >
    >> >
    >> > <ItemDetailsTemplate>
    >> > detail template:
    >> > <mobile:Label ID="Label1" Runat="server"><%# Eval("ID")
    >> > %></mobile:Label>
    >> > <mobile:Label ID="Label2" Runat="server"><%#

    Eval("UserTitle")
    >> > %></mobile:Label>
    >> >
    >> > </ItemDetailsTemplate>
    >> >
    >> > </Choice>
    >> >
    >> > </DeviceSpecific>
    >> >
    >> >
    >> > <Field Title="ID" DataField="ID" />
    >> > <Field Title="UserTitle" DataField="UserTitle" />
    >> > </mobile:ObjectList>
    >> > ========================
    >> >
    >> > Also, I found a good web forum thread which has included some advanced
    >> > setting and usage upon ObjectList control, you can also have a look

    if you
    >> > need some further customzation or event handling:
    >> >
    >> > http://forums.asp.net/p/1146753/1862202.aspx
    >> >
    >> > 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.
    >> >
    >> >
    >> >

    >
     
    Steven Cheng[MSFT], Sep 4, 2007
    #5
  6. Actually, the problem, it turns out, was that I was using
    <ItemDetailsTemplate> when I should have been using <ItemTemplate>. When I
    use that instead, the thing does what I need. I really appreciate all your
    help. One suggestion: The whole ObjectList, DeviceSpecific, etc., etc.
    business is, in my opinion, VERY poorly documented. Usually, you guys do a
    really good job of definition, how-to, etc. In this area, the documentation
    is really very poor.

    In any case, I'm okay now. I really appreciate all your help.

    Thanks.

    Alex

    "Steven Cheng[MSFT]" wrote:

    > Thanks for your followup Alex,
    >
    > For the "ItemDetailsTemplate" template issue you mentioned, it maybe still
    > due to the control use the default template since there may have any other
    > setting and prevent your custom one from display. Yes, mobile control is
    > not natually targeting html from its designate, so that does make us feel
    > abit inconvenient when we want to author standard html/xhtml content for
    > mobile page.
    >
    > BTW, as most smart devices not support html and asp.net standard
    > application control also have adaptable rendering model, maybe you can
    > consider use a standard aspx page here as you will mostly use html based
    > content. Is this possible in your application?
    >
    >
    > Sincerely,
    >
    > Steven Cheng
    >
    > Microsoft MSDN Online Support Lead
    >
    >
    > This posting is provided "AS IS" with no warranties, and confers no rights.
    >
    >
    > --------------------
    > >Thread-Topic: ObjectList Data-Binding to a List<MyClass>
    > >Date: Fri, 31 Aug 2007 07:52:01 -0700

    >
    > >
    > >Steven -
    > >
    > >One more note: I have successfully gotton it to show both columns by

    > adding
    > > TableFields="ID;UserTitle"
    > >to the <mobile:ObjectList...> tag. But I still can't get it to display
    > >standard text of mark-up that I have placed in the <ItemDetailsTemplate>.

    > It
    > >just ignores that and only displays the <mobile: Label...> objects that I
    > >have bound to my data fields. What is *with* this control?! Why is it so
    > >constrained? All I want is a control that allows me to manually build HTML
    > >markup for each object in a list (whether a database DataTable or some

    > other
    > >kind of list). I have that *so* easily with the Repeater control in

    > standard
    > >ASPX which allows me to repeat *anyuthing* over and over again based on

    > rows
    > >from a List. What that markup is that is sent to the browser is up to me

    > and
    > >if I include items that the browser can't handle, that's *my* problem. Why
    > >can't I do that in mobile. Sorry, but this is incredibly frustrating for
    > >something so simple.
    > >
    > >As always, thanks!
    > >
    > >Alex
    > >
    > >"Alex Maghen" wrote:
    > >
    > >> Steven -
    > >>
    > >> Thanks for getting back to me about all these posts. I have been away

    > and am
    > >> just getting back to it now. I must say, I find this entire approach
    > >> *incredibly* complicated for something as simple as providing a listing

    > of
    > >> objects/assets from a List or Database table. But there's nothing I can

    > do
    > >> about it, I guess so I have to keep bothering you until I really

    > understand.
    > >> I implemented exactly what you defined below and I'm no longer getting

    > the
    > >> error I was getting before, but I *am* still having a problem:
    > >>
    > >> In the <ItemDetailsTemplate> section (below), I've presented two
    > >> <mobile:Label ...> objects, one whose content is set to: <%# Eval("ID")

    > %>
    > >> and another whose content is set to <%# Eval("UserTitle") %>. I then

    > also
    > >> added the two <Field...> tags for ID and UserTitle below (just as you
    > >> defined). When I run this, though, all I see is a "table" with a single
    > >> column showing the "ID" header and "ID" entries only. The second label

    > for
    > >> the "UserTitle" is simply not shown. Also, in your sample, you placed

    > the
    > >> text "detail template:" just inside the <ItemDetailsTemplate> tag. This

    > is
    > >> literal text and I would have assumed that it would just show up in

    > every
    > >> row. Instead, it doesn't show up at all.
    > >>
    > >> Can you please help? This is an incredibly complicated way of doing
    > >> something really simple - or so it seems.
    > >>
    > >> Thanks as always.
    > >>
    > >> Alex
    > >>
    > >>
    > >>
    > >> "Steven Cheng[MSFT]" wrote:
    > >>
    > >> > Hi Alex,
    > >> >
    > >> > Seems this is a continual post from a former thread discussing on

    > "Mobile
    > >> > Repeater", correct?
    > >> >
    > >> > I've performed test through the code you provided and did met the

    > error you
    > >> > said. After some research, I found that the error is caused by no data
    > >> > fields are defined in the ObjectList control. Actually, if you turn

    > off
    > >> > "AutoGenerateFields" in ObjectList, you need to supply the fields you

    > want
    > >> > to use in your ObjectList. You should use the <Field > element to add
    > >> > fields definition into the ObjectList.
    > >> >
    > >> > For your "TestClass" scenario, here is the expected ObjectList aspx
    > >> > template:
    > >> >
    > >> > ================
    > >> > <mobile:ObjectList ID="ObjectList1" Runat="server"
    > >> > CommandStyle-StyleReference="subcommand"
    > >> > LabelStyle-StyleReference="title"

    > AutoGenerateFields="False"
    > >> > LabelField="UserTitle" >
    > >> >
    > >> > <DeviceSpecific ID="ds_ol1" Runat="server">
    > >> >
    > >> > <Choice >
    > >> >
    > >> >
    > >> >
    > >> > <ItemDetailsTemplate>
    > >> > detail template:
    > >> > <mobile:Label ID="Label1" Runat="server"><%# Eval("ID")
    > >> > %></mobile:Label>
    > >> > <mobile:Label ID="Label2" Runat="server"><%#

    > Eval("UserTitle")
    > >> > %></mobile:Label>
    > >> >
    > >> > </ItemDetailsTemplate>
    > >> >
    > >> > </Choice>
    > >> >
    > >> > </DeviceSpecific>
    > >> >
    > >> >
    > >> > <Field Title="ID" DataField="ID" />
    > >> > <Field Title="UserTitle" DataField="UserTitle" />
    > >> > </mobile:ObjectList>
    > >> > ========================
    > >> >
    > >> > Also, I found a good web forum thread which has included some advanced
    > >> > setting and usage upon ObjectList control, you can also have a look

    > if you
    > >> > need some further customzation or event handling:
    > >> >
    > >> > http://forums.asp.net/p/1146753/1862202.aspx
    > >> >
    > >> > 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.
    > >> >
    > >> >
    > >> >

    > >

    >
    >
     
    =?Utf-8?B?QWxleCBNYWdoZW4=?=, Sep 4, 2007
    #6
  7. Thanks for your followup Alex,

    Yes, <ItemTemplate> will be displayed first, while <ItemDetailsTemplate> is
    to displayed when a certain record is further choosen by the user. Anyway,
    I'm glad that you've got the one you want.

    For the document issue, I agree that the current samples and tutorials for
    ASP.NET Mobile application are so limited. I think it is also probably due
    to more users are focus on the standard web application developing. Anyway,
    your comments and feedback is really appreicated and I suggest you submit
    them to our feedback center:

    https://connect.microsoft.com/feedback/default.aspx?SiteID=210&wa=wsignin1.0

    You can also directly submit feedback through the web document page's
    feedback button (on msdn2.microsoft.com....).

    Thanks again for your posting and support to us!

    Sincerely,

    Steven Cheng

    Microsoft MSDN Online Support Lead


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



    --------------------
    >Thread-Topic: ObjectList Data-Binding to a List<MyClass>
    >From: =?Utf-8?B?QWxleCBNYWdoZW4=?= <>


    >
    >Actually, the problem, it turns out, was that I was using
    ><ItemDetailsTemplate> when I should have been using <ItemTemplate>. When I
    >use that instead, the thing does what I need. I really appreciate all your
    >help. One suggestion: The whole ObjectList, DeviceSpecific, etc., etc.
    >business is, in my opinion, VERY poorly documented. Usually, you guys do a
    >really good job of definition, how-to, etc. In this area, the

    documentation
    >is really very poor.
    >
    >In any case, I'm okay now. I really appreciate all your help.
    >
    >Thanks.
    >
    >Alex
    >
    >"Steven Cheng[MSFT]" wrote:
    >
    >> Thanks for your followup Alex,
    >>
    >> For the "ItemDetailsTemplate" template issue you mentioned, it maybe

    still
    >> due to the control use the default template since there may have any

    other
    >> setting and prevent your custom one from display. Yes, mobile control

    is
    >> not natually targeting html from its designate, so that does make us

    feel
    >> abit inconvenient when we want to author standard html/xhtml content for
    >> mobile page.
    >>
    >> BTW, as most smart devices not support html and asp.net standard
    >> application control also have adaptable rendering model, maybe you can
    >> consider use a standard aspx page here as you will mostly use html based
    >> content. Is this possible in your application?
    >>
    >>
    >> Sincerely,
    >>
    >> Steven Cheng
    >>
    >> Microsoft MSDN Online Support Lead
    >>
    >>
    >> This posting is provided "AS IS" with no warranties, and confers no

    rights.
    >>
    >>
    >> --------------------
    >> >Thread-Topic: ObjectList Data-Binding to a List<MyClass>
    >> >Date: Fri, 31 Aug 2007 07:52:01 -0700

    >>
    >> >
    >> >Steven -
    >> >
    >> >One more note: I have successfully gotton it to show both columns by

    >> adding
    >> > TableFields="ID;UserTitle"
    >> >to the <mobile:ObjectList...> tag. But I still can't get it to display
    >> >standard text of mark-up that I have placed in the

    <ItemDetailsTemplate>.
    >> It
    >> >just ignores that and only displays the <mobile: Label...> objects that

    I
    >> >have bound to my data fields. What is *with* this control?! Why is it

    so
    >> >constrained? All I want is a control that allows me to manually build

    HTML
    >> >markup for each object in a list (whether a database DataTable or some

    >> other
    >> >kind of list). I have that *so* easily with the Repeater control in

    >> standard
    >> >ASPX which allows me to repeat *anyuthing* over and over again based on

    >> rows
    >> >from a List. What that markup is that is sent to the browser is up to

    me
    >> and
    >> >if I include items that the browser can't handle, that's *my* problem.

    Why
    >> >can't I do that in mobile. Sorry, but this is incredibly frustrating

    for
    >> >something so simple.
    >> >
    >> >As always, thanks!
    >> >
    >> >Alex
    >> >
    >> >"Alex Maghen" wrote:
    >> >
    >> >> Steven -
    >> >>
    >> >> Thanks for getting back to me about all these posts. I have been away

    >> and am
    >> >> just getting back to it now. I must say, I find this entire approach
    >> >> *incredibly* complicated for something as simple as providing a

    listing
    >> of
    >> >> objects/assets from a List or Database table. But there's nothing I

    can
    >> do
    >> >> about it, I guess so I have to keep bothering you until I really

    >> understand.
    >> >> I implemented exactly what you defined below and I'm no longer

    getting
    >> the
    >> >> error I was getting before, but I *am* still having a problem:
    >> >>
    >> >> In the <ItemDetailsTemplate> section (below), I've presented two
    >> >> <mobile:Label ...> objects, one whose content is set to: <%#

    Eval("ID")
    >> %>
    >> >> and another whose content is set to <%# Eval("UserTitle") %>. I then

    >> also
    >> >> added the two <Field...> tags for ID and UserTitle below (just as you
    >> >> defined). When I run this, though, all I see is a "table" with a

    single
    >> >> column showing the "ID" header and "ID" entries only. The second

    label
    >> for
    >> >> the "UserTitle" is simply not shown. Also, in your sample, you placed

    >> the
    >> >> text "detail template:" just inside the <ItemDetailsTemplate> tag.

    This
    >> is
    >> >> literal text and I would have assumed that it would just show up in

    >> every
    >> >> row. Instead, it doesn't show up at all.
    >> >>
    >> >> Can you please help? This is an incredibly complicated way of doing
    >> >> something really simple - or so it seems.
    >> >>
    >> >> Thanks as always.
    >> >>
    >> >> Alex
    >> >>
    >> >>
    >> >>
    >> >> "Steven Cheng[MSFT]" wrote:
    >> >>
    >> >> > Hi Alex,
    >> >> >
    >> >> > Seems this is a continual post from a former thread discussing on

    >> "Mobile
    >> >> > Repeater", correct?
    >> >> >
    >> >> > I've performed test through the code you provided and did met the

    >> error you
    >> >> > said. After some research, I found that the error is caused by no

    data
    >> >> > fields are defined in the ObjectList control. Actually, if you turn

    >> off
    >> >> > "AutoGenerateFields" in ObjectList, you need to supply the fields

    you
    >> want
    >> >> > to use in your ObjectList. You should use the <Field > element to

    add
    >> >> > fields definition into the ObjectList.
    >> >> >
    >> >> > For your "TestClass" scenario, here is the expected ObjectList aspx
    >> >> > template:
    >> >> >
    >> >> > ================
    >> >> > <mobile:ObjectList ID="ObjectList1" Runat="server"
    >> >> > CommandStyle-StyleReference="subcommand"
    >> >> > LabelStyle-StyleReference="title"

    >> AutoGenerateFields="False"
    >> >> > LabelField="UserTitle" >
    >> >> >
    >> >> > <DeviceSpecific ID="ds_ol1" Runat="server">
    >> >> >
    >> >> > <Choice >
    >> >> >
    >> >> >
    >> >> >
    >> >> > <ItemDetailsTemplate>
    >> >> > detail template:
    >> >> > <mobile:Label ID="Label1" Runat="server"><%# Eval("ID")
    >> >> > %></mobile:Label>
    >> >> > <mobile:Label ID="Label2" Runat="server"><%#

    >> Eval("UserTitle")
    >> >> > %></mobile:Label>
    >> >> >
    >> >> > </ItemDetailsTemplate>
    >> >> >
    >> >> > </Choice>
    >> >> >
    >> >> > </DeviceSpecific>
    >> >> >
    >> >> >
    >> >> > <Field Title="ID" DataField="ID" />
    >> >> > <Field Title="UserTitle" DataField="UserTitle" />
    >> >> > </mobile:ObjectList>
    >> >> > ========================
    >> >> >
    >> >> > Also, I found a good web forum thread which has included some

    advanced
    >> >> > setting and usage upon ObjectList control, you can also have a

    look
    >> if you
    >> >> > need some further customzation or event handling:
    >> >> >
    >> >> > http://forums.asp.net/p/1146753/1862202.aspx
    >> >> >
    >> >> > 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.
    >> >> >
    >> >> >
    >> >> >
    >> >

    >>
    >>

    >
     
    Steven Cheng[MSFT], Sep 5, 2007
    #7
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mario Fratelli
    Replies:
    32
    Views:
    1,439
    Phlip
    Dec 9, 2003
  2. Dave
    Replies:
    1
    Views:
    363
    Ron Natalie
    Dec 8, 2003
  3. modemer
    Replies:
    11
    Views:
    656
    modemer
    Mar 21, 2005
  4. Gunnar G
    Replies:
    5
    Views:
    386
    Howard
    Jul 8, 2005
  5. tom
    Replies:
    5
    Views:
    425
Loading...

Share This Page