LogicTemplates
The LogicTemplate controls simplify conditional presentation logic. These controls allow you to dynamically control the contents of templates in repeater controls (DataGrid, DataRepeater, etc). LogicTemplates provide easier, cleaner code than using OnItemCreated events or other code-behind functions.
Features
- Allow easy addition of conditional logic with data-binding expressions.
- Enable the creation of 'if' and 'switch' structures, including nesting.
- LogicTemplates do not databind their contents unless they test "true", allowing
data-binding expression that might otherwise throw an exception.
Code Example
<%@ Register TagPrefix="fluent" Namespace="Fluent.LogicTemplates" Assembly="Fluent.LogicTemplates" %>
<html>
<head>
<script language="C#" runat="server">
private void Page_Load(object sender, System.EventArgs e) {
if(!IsPostBack){
BindDataList();
}
}
private void BindDataList() {
...
}
</script>
</head>
<body>
<form runat="server">
<asp:DataList Runat="server" ID="DataListProducts" ItemStyle-CssClass="listing" CellSpacing="4">
<ItemTemplate>
<h2><%# DataBinder.Eval(Container.DataItem,"name") %></h2>
<p><%# DataBinder.Eval(Container.DataItem,"description") %></p>
Quantity: <%# DataBinder.Eval(Container.DataItem,"quantity") %><br />
<Fluent:Choose Runat="server">
<Fluent:When Runat="server" Test='<%# (int)DataBinder.Eval(Container.DataItem,"quantity") == 0 %>' >
Sold Out!<br />
</Fluent:When>
<Fluent:When Runat="server" Test='<%# (int)DataBinder.Eval(Container.DataItem,"quantity") < 10 %>' >
Hurry, supplies are limited!<br />
</Fluent:When>
<Fluent:Otherwise Runat="server">
Order now!<br />
</Fluent:Otherwise>
</Fluent:Choose>
</ItemTemplate>
</asp:DataList>
</form>
</body>
</html>
Copyright © 2002-2003 Fluent Consulting. All rights reserved.