RE: If Then statement inside of repeater control
From: Steven Cheng[MSFT] (v-schang_at_online.microsoft.com)
Date: 10/22/04
- Next message: Hans Kesting: "Re: Problem with foreach loop"
- Previous message: Kevin Wen: "How to determine if an user belongs to a specific group?"
- In reply to: sck10: "If Then statement inside of repeater control"
- Next in thread: Steven Cheng[MSFT]: "RE: If Then statement inside of repeater control"
- Reply: Steven Cheng[MSFT]: "RE: If Then statement inside of repeater control"
- Messages sorted by: [ date ] [ thread ]
Date: Fri, 22 Oct 2004 08:27:05 GMT
Hi Sck10,
Thanks for your posting. As for the problem you mentioned, here are some of
my understandings:
1. The<% %> expression is only used in page(or UserControl, ascx) 's page
level template , but unable to be used in any asp.net web server control's
databinding template. We can only use <%# %> databinding expression to
bind value to asp.net server control's properties or template. For example:
<asp:TextBox ... Text="<% ...%>" ...> is not allowed,
we should use <asp:TextBox ... Text=<%# .. %> ..>
Also, the expression or code will be called when the TextBox (or its parent
container )'s DataBind method is called.
2. As for your problem, I think you should put the If ...else statement
logic into the <#% %> block . Forexample:
<ItemTemplate>
<%# GetHeader( Container.DataItem("Status") ) %>
<tr>
<td width="120"><%# Container.DataItem("Status") %></div></td>
<td width="80"><%# Container.DataItem("StatusCount") %></div></td>
<td width="80"><%# Container.DataItem("PercentTotal") %>%</div></td>
</tr>
</ItemTemplate>
GetHeader( string) is a helper function defined in the codebehind class
which return the correct html depend on the input param. such as:
#must be protected or public so that we can call it in aspx page's inline
code
protected string GetHeader(string status)
{
if(status== xxx)
{
return "<tr><td width=\"280\" colspan=\"3\"><hr
color=#0000FF></td></tr>";
}else
{
return string.Empty;
}
}
Hope helps. IF you have anything else unclear, please feel free to post
here. Thanks.
Regards,
Steven Cheng
Microsoft Online Support
Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
- Next message: Hans Kesting: "Re: Problem with foreach loop"
- Previous message: Kevin Wen: "How to determine if an user belongs to a specific group?"
- In reply to: sck10: "If Then statement inside of repeater control"
- Next in thread: Steven Cheng[MSFT]: "RE: If Then statement inside of repeater control"
- Reply: Steven Cheng[MSFT]: "RE: If Then statement inside of repeater control"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|