[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Elie Khammar

6/5/2002 8:51:00 PM

If I have 3 columns CustomerId, CustomerName,
CustomerAddress in a table and I want to display only two
columns customerName and CustomerAddress. My question is:
How can I figure out which CustomerId was selected from
the Object List to be able to display its corresponding
detail.
1 Answer

(Simon Calvert)

6/6/2002 5:56:00 PM

0

Are you using a templated objectlist to produce the table form of the
listview, or using the TableFields property? In the latter case, you should
get a table in the listview on an HTML client, with the initial field being
a link to the detailsview.

In the former case for an HTML client, you can bind the dataset to your
objectlist, (!IsPostback). Template the objecllist producing a table with
the fields you require. For the field that you want as the clickable item
to show details, build a mobile:command, then handle the onitemcommand
event for the objectlist. The button click of this command bubbles to the
parent. In the event, set the selected index for the objectlist to the
listItem's index, and set the objectlist's Viewmode to details.

<mobile:ObjectList id=ObjectList1 runat="server" DataSource="<%# dataSet11
%>" DataMember="Customers" OnItemCommand="OnItemCommand">
<DeviceSpecific>
<Choice Filter="isHTML32"
Xmlns="http://schemas.microsoft.com/mobile/html32template...
<HeaderTemplate>
<table>
</HeaderTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
<ItemTemplate>
<tr><td>
<mobile:Command Format="Link" Runat="server"
CommandName="Details" Text='<%#
((ObjectListItem)(Container))["ContactName"] %>' />
</td>
<td><%# ((ObjectListItem)(Container))["Address"] %>
</td>
</tr>
</ItemTemplate>
</Choice>
</DeviceSpecific>
</mobile:ObjectList>

in the code-behind

public void OnItemCommand(object sender,
System.Web.UI.MobileControls.ObjectListCommandEventArgs e)
{
// Set the mode of the objectlist
if (e.CommandName != "Back")
{
ObjectList1.SelectedIndex = e.ListItem.Index;
ObjectList1.ViewMode = ObjectListViewMode.Details;
}
else
{
ObjectList1.ViewMode = ObjectListViewMode.List;
}
}


I hope this helps, if not, please provide more details about your scenario.

Simon.
This posting is provided "AS IS" with no warranties, and confers no rights.
You assume all risk for your use. © 2002 Microsoft Corporation. All rights
reserved.