|
-
Jan 5th, 2003, 08:01 PM
#1
Thread Starter
Hyperactive Member
Datalist and template
Hi, I have a datalist that is used in conjunction to display values
retrieved from a database:
What I would like to do is check the value of a field and then do something
(Change a label or whatever).
Below is my code
VB Code:
' Create a datalist
<asp:DataList id="MyList" RepeatColumns="2" runat="server">
<ItemTemplate>
<table border="0" width="272">
<tr>
<td width="25">
 
</td>
' I would like to check the value of the following item and then do
' something if the item is less than 0
' e.g if DataBinder.Eval(Container.DataItem, "UnitCost", "{0:c}") < 0
' then response.write("hi")
<span class="ProductListItem">
<%# DataBinder.Eval(Container.DataItem, "UnitCost", "{0:c}")
%>
</span>
Any help appreciated
Cheers
Mark
-
Jan 6th, 2003, 12:23 AM
#2
Fanatic Member
you could put a Label in the ItemTemplate, fill it with your initial unchecked value:
<asp:Label Runat="server" ID="lblUnitCost" Text='<%# Container.DataItem("UnitPrice") %>' Visible="False" />
Then loop through all your Items in the Datalist, and then check the value in the label... then do something with it then depending on what you need to do I don't think you can have Conditional statements in the ItemTemplate... :/ i could be wrong though, but i seem to remember trying to do something similar, and it wouldn't let me use an If Then Statement....
-
Jan 6th, 2003, 02:23 AM
#3
Thread Starter
Hyperactive Member
Resolved
Hi, I have found a way to do it using a function. Apparantly you can call a function but not a subroutine from inside a template.
more info here
http://aspalliance.com/Colt/Articles/Article1.aspx
Thanks for your help
Regards
Mark
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|