Helper function problems

2

276q

I'm trying to display header text in my repeater control on a
condition if a record exists in my resultset. I cannot get 'cat' to
display the "category" record from my resultset (the delimiters are
wrong in this context of a repeater control):

<% dim cat
cat = <%# Container.DataItem("category")%>
Function ShowRealty(cat)

If cat = "realty" Then
ShowRealty = "Realty Companies In Mytown"
Else if
cat = "" then
ShowRealty = "No Listings Yet"
End If
End Function %>
<HeaderTemplate>
<%=ShowRealty(cat)%>
</HeaderTemplate>

????
Ed
 
G

Guest

I'm trying to display header text in my repeater control on a
condition if a record exists in my resultset. I cannot get 'cat' to
display the "category" record from my resultset (the delimiters are
wrong in this context of a repeater control):

<% dim cat
cat = <%# Container.DataItem("category")%>
Function ShowRealty(cat)

If cat = "realty" Then
ShowRealty = "Realty Companies In Mytown"
Else if
cat = "" then
ShowRealty = "No Listings Yet"
End If
End Function %>
<HeaderTemplate>
<%=ShowRealty(cat)%>
</HeaderTemplate>

????
Ed

<%#ShowRealty(Eval("cat"))%>
 
2

276q

Thanks for reply. Really my main concern is how to integrate this into
a repeater control . I don't have VS.Net, so I it's hard to use code
behind, or use IDE for click and drag help for this. I get a
"Declaration Expected" compilation error on line where cat =
(Eval("category") when trying to run this

'''''''''''''
<asp:repeater id="myRepeater" runat="server">


dim cat
cat = (Eval("category"))

public Function ShowRealty(cat)
If cat = "realty" Then
ShowRealty = "Realty Companies In Mytown"
Else if
cat = "" then
ShowRealty = "No Listings Yet"
End If
End Function

<HeaderTemplate>


<%#ShowRealty(Eval("cat"))%>
</HeaderTemplate>
'''''
 
G

Guest

Thanks for reply. Really my main concern is how to integrate this into
a repeater control . I don't have VS.Net, so I it's hard to use code
behind, or use IDE for click and drag help for this. I get a
"Declaration Expected" compilation error on line where cat =
(Eval("category") when trying to run this

'''''''''''''
<asp:repeater id="myRepeater" runat="server">

dim cat
cat = (Eval("category"))

public Function ShowRealty(cat)
If cat = "realty" Then
ShowRealty = "Realty Companies In Mytown"
Else if
cat = "" then
ShowRealty = "No Listings Yet"
End If
End Function

<HeaderTemplate>

<%#ShowRealty(Eval("cat"))%>
</HeaderTemplate>
'''''

it's a code-in-line... code-behind placed into a separate file.

Regarding your code: you can't use it in this way. The method should
be declared within <script runat="server"> blocks
placed before the <html> tag, and not between ASP <%...%>.

<script runat="server">
Function ShowRealty(ByVal cat as String)
.....
End Function
</script>

http://msdn2.microsoft.com/en-us/library/f0111sbh.aspx

Hope it helps
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,901
Latest member
Noble71S45

Latest Threads

Top