[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

microsoft.public.dotnet.framework.aspnet.mobile

ObjectList Control & templates

PP

5/7/2002 6:17:00 PM

How do I access the table row named "row1"
within "ObjLst_ItemDataBound"? I want to selectively set
its visible property to "false" during the databinding .
Are there any code samples on objectlist and template? Any
help would be appreciated.


<mobile:Form id="Form1" runat="server">
<mobile:ObjectList id="ObjLst" AutoGenerateFields="true"
OnItemDataBind="ObjLst_ItemDataBound" Runat="server">
<DeviceSpecific>
<Choice Argument="isHtml32">
<ItemTemplate>
<Table Runat="server">
<tr ID="row1" Runat="server" >
<td>Order Number: </td>
<td><%# ((ObjectListItem)Container)["Order_Num"]%></td>
</tr>
</table>
</ItemTemplate>
</Choice>
</DeviceSpecific>
</mobile:ObjectList>
</mobile:Form>
2 Answers

(Andres Sanabria)

6/5/2002 6:58:00 PM

0

Below is a sample code that resolve the issue.

ASPX Page

<mobile:ObjectList id=ObjectList1 runat="server"
CommandStyle-StyleReference="subcommand" LabelStyle-StyleReference="title"
DataSource="<%# dataSet11 %>" DataMember="Employees">
<DeviceSpecific>
<Choice Argument="isHtml32">
<ItemTemplate><asp:Table id="Table1" runat="server">
<asp:TableRow runat=server>
<asp:TableCell id="cell1" Visible="true">Order
Number:</asp:TableCell>
<asp:TableCell id="cell2" Visible="true">
<%# ((ObjectListItem)Container)["LastName"]%>
</asp:TableCell>
</asp:TableRow></asp:Table>
</ItemTemplate>
</Choice>
</DeviceSpecific>
</mobile:ObjectList>


CS Code Behind
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
sqlDataAdapter1.Fill(dataSet11);
Page.DataBind();
Control ctrlTemp = FindControlFromControlTree(ObjectList1,"cell1");
}

private Control FindControlFromControlTree(Control myControl, string
controlToFindID)
{
int tempCounter = 0;
Control mcTemp = null;
if (myControl.HasControls())
{
mcTemp = (Control)myControl.FindControl(controlToFindID);
if (mcTemp != null)
return mcTemp;
else
{
for (int i = 0 ; i<myControl.Controls.Count; i++)
{
Control child = (Control)myControl.Controls[i];
mcTemp = FindControlFromControlTree(child,controlToFindID);
if (mcTemp !=null)
//changed this line if you want to change the seting per item
mcTemp.Visible=false;
}
}
}
return null;
}

hopes this resolve the issue

AndresS

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.

Pansy

7/16/2002 4:29:00 AM

0

hi,
how do i modify the below given codes to make it such
that, the whole database is displayed out as a table, and
not each row as a table? (coz when i tried those codes
inside my application, the columns are not align
properly...)

i tried to use HeaderTemplate, and put the table start-
tag inside, and the table end-tag inside the
FooterTemplate... but it can't work.

how do i do that? thanks.

-Pansy

>-----Original Message-----
>Below is a sample code that resolve the issue.
>
>ASPX Page
>
><mobile:ObjectList id=ObjectList1 runat="server"
>CommandStyle-StyleReference="subcommand" LabelStyle-
StyleReference="title"
>DataSource="<%# dataSet11 %>" DataMember="Employees">
> <DeviceSpecific>
> <Choice Argument="isHtml32">
> <ItemTemplate><asp:Table id="Table1"
runat="server">
> <asp:TableRow runat=server>
> <asp:TableCell id="cell1"
Visible="true">Order
>Number:</asp:TableCell>
> <asp:TableCell id="cell2" Visible="true">
> <%# ((ObjectListItem)Container)
["LastName"]%>
> </asp:TableCell>
> </asp:TableRow></asp:Table>
> </ItemTemplate>
> </Choice>
> </DeviceSpecific>
> </mobile:ObjectList>
>
>
>CS Code Behind
> private void Page_Load(object sender, System.EventArgs e)
> {
> // Put user code to initialize the page here
>sqlDataAdapter1.Fill(dataSet11);
>Page.DataBind();
>Control ctrlTemp = FindControlFromControlTree
(ObjectList1,"cell1");
>}
>
>private Control FindControlFromControlTree(Control
myControl, string
>controlToFindID)
>{
>int tempCounter = 0;
>Control mcTemp = null;
>if (myControl.HasControls())
>{
>mcTemp = (Control)myControl.FindControl
(controlToFindID);
>if (mcTemp != null)
>return mcTemp;
>else
>{
>for (int i = 0 ; i<myControl.Controls.Count;
i++)
>{
>Control child = (Control)myControl.Controls[i];
>mcTemp = FindControlFromControlTree
(child,controlToFindID);
>if (mcTemp !=null)
>//changed this line if you want to change the seting per
item
> mcTemp.Visible=false;
>}
>}
>}
>return null;
>}
>
>hopes this resolve the issue
>
>AndresS
>
>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.
>
>.
>