|
-
Oct 8th, 2003, 12:04 PM
#1
Thread Starter
Frenzied Member
Conditional Behavior with Databound repeater
VB Code:
<%If Not DataBinder.Eval(Container.DataItem, "Discontinued") = True Then%>
<a href="placeOrder.aspx?ProdID=<%# DataBinder.Eval(Container.DataItem,"ProductID")%>" style="text-decoration: none;">Order Now</a>
<%Else%>
Discontinued
<%End If%>
that code will not run. How do I get the same effect? I can't find away to get the data I need inside an if block....... I'm Using a Repetear bound to a DataSet and everything works fine if i take out the if block but I need it.....
Thanks for any help you guys.
Magiaus
If I helped give me some points.
-
Oct 8th, 2003, 01:01 PM
#2
PowerPoster
Call a public function and return a string. Pass in your Discontinued variable. Something like this:
Code:
<% MyStringFunction(DataBinder.Eval(Container.DataItem, "Discontinued")) %>
And your function:
Code:
Public Function MyStringFunction(ByVal obj as Object) As String
If CType(obj, Boolean) = True Then
MyStringFunction = "<a href="placeOrder.aspx?ProdID=<%# DataBinder.Eval(Container.DataItem,"ProductID")%>" style="text-decoration: none;">Order Now</a>"
Else
MyStringFunction = "Discontinued"
End If
End Function
This was all done by hand and memory, so it may not work out of the box. But it is a good start in the direction you want to go. I have done this type of stuff myself.
-
Oct 8th, 2003, 01:05 PM
#3
Thread Starter
Frenzied Member
I'll give that a try. I think the problem is that every where I have seen DataBinder used it <%# DataBinder%> I'll post and let you know if your idea works.
Magiaus
If I helped give me some points.
-
Oct 9th, 2003, 05:38 PM
#4
Usually, I do the following.
Keep in mind that iif will probably be deprecated, but it's functionality could easily be duplicated with a user-written Function.
::
<span style='<%#iif(Container.DataItem("Discontinued") , "display:none", "")%>'>
MyStringFunction = "<a href="placeOrder.aspx?ProdID=<%# DataBinder.Eval(Container.DataItem,"ProductID")%>" style="text-decoration: none;">Order Now</a>"
</span>
<span style='<%#iif(not Container.DataItem("Discontinued") , "display:none", "")%>'>
Discontinued
</span>
Need to re-register ASP.NET?
C:\WINNT\Microsoft.NET\Framework\v#VERSIONNUMBER#\aspnet_regiis -i
(Edit #VERSIONNUMBER# as needed - do a DIR if you don't know)
-
Oct 10th, 2003, 03:21 PM
#5
Thread Starter
Frenzied Member
Magiaus
If I helped give me some points.
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
|