Can't seem to get ItemDetailsTemplate to work for me :(

Discussion in 'ASP .Net Mobile' started by Rich, Sep 29, 2004.

  1. Rich

    Rich Guest

    I have an ObjectList which I am populating from a SQL Server database (a join
    accross several tables). I have customized the ObjectList display with
    ItemTemplate and Alternating ItemTemplate, and pass CommandName to the
    ItemCommand message handler so that the user can either drill into the item
    details or perform a followon task associated with the item. When I use the
    default item details display all is well. However, I would like to customize
    the item details display just as I have customized the parent item display. I
    tried to closely follow the example in Wigley/Roxburgh's "Building Microsoft
    ASP.NET Applications for Mobile Devices", but the customized item details
    page does not contain my data (although a "view source" in IE6 shows that the
    "<br />" tags in my ItemDetailsTemplate did get passed to the details page).
    Any idea why I am not getting the "meat" of my data
    (start;lastname;firstname;name)?

    Here is part of the code from the aspx page:
    <mobile:ObjectList id="olstTask" runat="server" ItemsPerPage="5"
    CommandStyle-StyleReference="subcommand" LabelStyle-StyleReference="title"
    Font-Size="Small" TableFields="start;lastname;firstname;name">
    <Field Title="Due" DataFormatString="{0:MM/d h:mm}"
    DataField="start"></Field>
    <Field Title="Patient" DataField="lastname"></Field>
    <Field DataField="firstname"></Field>
    <Field Title="Task" DataField="name"></Field>
    <DeviceSpecific>
    <Choice Filter="isHTML32"
    Xmlns="http://schemas.microsoft.com/mobile/html32template">
    <HeaderTemplate>
    <TABLE id="Table1" cellSpacing="1" cellPadding="1" width="300" border="0">
    <TR>
    <TD><IMG alt="Sea State 1" src="ss1_logo.png"></TD>
    </TR>
    </HeaderTemplate>
    <ItemTemplate>
    <TR>
    <TD><asp:LinkButton ID="lbnStart" CommandName="doTask" Runat="server">
    <%# ((ObjectListItem)Container)["start"] %></asp:LinkButton>
    </TD>
    <TD><%# ((ObjectListItem)Container)["lastname"] %></TD>
    <TD><%# ((ObjectListItem)Container)["firstname"] %></TD>
    <TD><asp:LinkButton ID="lbnTask" CommandName="details" Runat="server">
    <%# ((ObjectListItem)Container)["name"] %></asp:LinkButton></TD>
    </TR>
    </ItemTemplate>
    <AlternatingItemTemplate>
    <TR bgcolor="#ccffcc">
    <TD>
    <asp:LinkButton ID="lbnStart_alt" CommandName="doTask" Runat="server">
    <%# ((ObjectListItem)Container)["start"] %>
    </asp:LinkButton>
    </TD>
    <TD><%# ((ObjectListItem)Container)["lastname"] %></TD>
    <TD><%# ((ObjectListItem)Container)["firstname"] %></TD>
    <TD>
    <asp:LinkButton ID="lbnTask_alt" CommandName="details" Runat="server">
    <%# ((ObjectListItem)Container)["name"] %>
    </asp:LinkButton>
    </TD>
    </TR>
    </AlternatingItemTemplate>
    <ItemDetailsTemplate>
    <%#
    DataBinder.Eval(((ObjectList)Container.NamingContainer).Selection.DataItem,
    "start", "Due to start: {0}") %>
    <br/>
    <%#
    DataBinder.Eval(((ObjectList)Container.NamingContainer).Selection.DataItem,
    "firstname", "Patient name: {0}") %>
    <%#
    DataBinder.Eval(((ObjectList)Container.NamingContainer).Selection.DataItem,
    "lastname", " {0}") %>
    <br/>
    <%#
    DataBinder.Eval(((ObjectList)Container.NamingContainer).Selection.DataItem,
    "name", "Task: {0}") %>
    </ItemDetailsTemplate>
    <FooterTemplate>
    </TABLE>
    </FooterTemplate>
    </Choice>
    </DeviceSpecific>
    </mobile:ObjectList>
    Rich, Sep 29, 2004
    #1
    1. Advertising

  2. The following worked for me:

    <%#
    ((ObjectListItem)(((ObjectList)(Container.NamingContainer)).Selection))["something"] %>

    I could not make DataBinder.Eval work for me, so I used this.
    You may use String.Format to format your data.
    Nozomu Hirose, Nov 14, 2004
    #2
    1. Advertising

  3. Rich

    Rich Guest

    Great tip! It worked very well. Thanks.

    "Nozomu Hirose" wrote:

    > The following worked for me:
    >
    > <%#
    > ((ObjectListItem)(((ObjectList)(Container.NamingContainer)).Selection))["something"] %>
    >
    > I could not make DataBinder.Eval work for me, so I used this.
    > You may use String.Format to format your data.
    >
    >
    >
    Rich, Nov 20, 2004
    #3
  4. Rich

    Trine Guest

    Please has anyone tried to add a checkbox column to an obejctlist AND
    suceeded in taking a boolean value from a dataset to check or uncheck it.
    I have the following code which give me a devicespecific templated checkbox
    (it only displays a checkbox) :

    <mobile:SelectionList SelectType="ChekcBox" ..... >
    <Item Selected='<%#
    Convert.ToBoolean(((ObjectListItem)(((ObjectList)(Container.NamingContainer)).Selection))["primaryvalue"])%></Item>
    </mobile:SelectionList>

    in another objectlist I try a different approach and this code brings me the
    boolean value in text:
    <Field Title="Primary Value" Name="primaryvalue"
    DataField="primaryvalue"></Field>

    but I cant seem to make the two things work together. Any suggestions?
    Trine, Nov 23, 2004
    #4
    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. Jack Schafer
    Replies:
    1
    Views:
    520
    Joe Smith
    Apr 23, 2004
  2. tfs
    Replies:
    1
    Views:
    355
    Ken Cox [Microsoft MVP]
    Jun 28, 2004
  3. =?Utf-8?B?Q2hyaXM=?=

    Help with hyperlinkcolumn, I can't seem to get it work!

    =?Utf-8?B?Q2hyaXM=?=, Feb 2, 2005, in forum: ASP .Net
    Replies:
    4
    Views:
    411
    =?Utf-8?B?Q2hyaXM=?=
    Feb 2, 2005
  4. Ranginald
    Replies:
    3
    Views:
    599
    Ray Booysen
    May 25, 2006
  5. Ersin Inan

    ObjectList <ItemDetailsTemplate>

    Ersin Inan, Jan 12, 2004, in forum: ASP .Net Mobile
    Replies:
    0
    Views:
    111
    Ersin Inan
    Jan 12, 2004
Loading...

Share This Page