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

R

Rich

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>
 
N

Nozomu Hirose

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.
 
T

Trine

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?
 

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

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top