473,386 Members | 1,819 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Help with Dynamic repeater...

Hi

I have a page that displays business listings. I have a repeater with dynamic text and in the 4th column I have an email and website link. Both display properly but I need to have one take precedent over the other, so if ("www") is not null then it should be displayed and the email shouldn't. I also need some script to only display either if the field is not null.

This is not really my thing, and I have been trying to figure this out all day so any help would be greatly appreciated:)

John Pether

<code>
<%
While ((Repeat1__numRows <> 0) AND (NOT listings.EOF))
%>
<tr>
<td><%=(listings.Fields.Item("BusinessName").Value )%><br /> <%=(listings.Fields.Item("Address1").Value)%><%=(l istings.Fields.Item("Address2").Value)%><br /> <%=(listings.Fields.Item("SubPost").Value)%><br /> </td>
<td><%=(listings.Fields.Item("Phone").Value)%></td>
<td><%=(listings.Fields.Item("Fax").Value)%></td>
<td><a href="mailto:<%=(listings.Fields.Item("Email").Val ue)%>">Email Us</a><br>><a href="<%=(listings.Fields.Item("WWW").Value)%>">Vi sit Us</a></td>
<td</td>
</tr>
<tr>
<td colspan=4><hr></td>
</tr>
<%
Repeat1__index=Repeat1__index+1
Repeat1__numRows=Repeat1__numRows-1
listings.MoveNext()
Wend
%>

************************************************** ********************
Sent via Fuzzy Software @ http://www.fuzzysoftware.com/
Comprehensive, categorised, searchable collection of links to ASP & ASP.NET resources...
Jul 19 '05 #1
4 4823
Change:
<td><a href="mailto:<%=(listings.Fields.Item("Email").Val ue)%>">Email
Us</a><br>><a href="<%=(listings.Fields.Item("WWW").Value)%>">Vi sit
Us</a></td>

to

<td><%=GetContactDetails(listings)%></td>

and later on, paste:

<%
Function GetContactDetails( _
ByRef listings _
)

If isNull(listings.Fields.Item("WWW") then
GetContactDetails = "<a href=""mailto:""" &
listings.Fields.Item("Email").Value & """>"
Else
GetContactDetails = "<a href=""mailto:""" &
listings.Fields.Item("WWW").Value & """>"
End If

End Function
%>
Note: I do not recommend this, as you're passing a recordset object around
to the function. Better would be, if you have to keep the recordset object,
to allocate the variables to strings, then pass in the strings, eg:

<%
strEmail = listings.Fields.Item("Email").Value
strWWW = listings.Fields.Item("WWW").Value
%>
<td><%=GetContactDetails(strEmail, strWWW)%></td>

, and then change the first line of the function to:

Function GetContactDetails( _
ByVal strEmail, _
ByVal strWWW _
)

HTH

Cheers
Ken


"John Pether" <john@<nospam>dotnetsites.net> wrote in message
news:eE**************@TK2MSFTNGP12.phx.gbl...
: Hi
:
: I have a page that displays business listings. I have a repeater with
dynamic text and in the 4th column I have an email and website link. Both
display properly but I need to have one take precedent over the other, so if
("www") is not null then it should be displayed and the email shouldn't. I
also need some script to only display either if the field is not null.
:
: This is not really my thing, and I have been trying to figure this out all
day so any help would be greatly appreciated:)
:
: John Pether
:
: <code>
: <%
: While ((Repeat1__numRows <> 0) AND (NOT listings.EOF))
: %>
: <tr>
: <td><%=(listings.Fields.Item("BusinessName").Value )%><br />
<%=(listings.Fields.Item("Address1").Value)%><%=(l istings.Fields.Item("Addre
ss2").Value)%><br /> <%=(listings.Fields.Item("SubPost").Value)%><br />
</td>
: <td><%=(listings.Fields.Item("Phone").Value)%></td>
: <td><%=(listings.Fields.Item("Fax").Value)%></td>
: <td><a
href="mailto:<%=(listings.Fields.Item("Email").Val ue)%>">Email Us</a><br>><a
href="<%=(listings.Fields.Item("WWW").Value)%>">Vi sit Us</a></td>
: <td</td>
: </tr>
: <tr>
: <td colspan=4><hr></td>
: </tr>
: <%
: Repeat1__index=Repeat1__index+1
: Repeat1__numRows=Repeat1__numRows-1
: listings.MoveNext()
: Wend
: %>
:
: ************************************************** ********************
: Sent via Fuzzy Software @ http://www.fuzzysoftware.com/
: Comprehensive, categorised, searchable collection of links to ASP &
ASP.NET resources...
Jul 19 '05 #2
ok, great thanks for your help. I had a few probs with the code, syntax etc...but got through that....however nuthing is appearing on the page. I have used the code below but even though there is an entry in the www field, nothing is showing on the page.

I also do not see how this would allow "www" to take precedent over "email" if they both have data in the fields....

Once again thanks for your help and I hope you/someone can help me get this working:)

<td valign="top"><%=GetContactDetails(strEmail, strWWW)%></td>

<%
strEmail = listings.Fields.Item("Email").Value
strWWW = listings.Fields.Item("WWW").Value
%>
<%
Function GetContactDetails( _
ByVal strEmail, _
ByVal strWWW _
)

If isNull(listings.Fields.Item("WWW")) then
GetContactDetails = "<a href=""mailto:""" & listings.Fields.Item("Email").Value & """>"
Else
GetContactDetails = "<a href=""http://""" & listings.Fields.Item("WWW").Value & """>"
End If

End Function
%>

************************************************** ********************
Sent via Fuzzy Software @ http://www.fuzzysoftware.com/
Comprehensive, categorised, searchable collection of links to ASP & ASP.NET resources...
Jul 19 '05 #3
Hi,

You need to assign the values to the variables *before* you call the
function, otherwise when you call the function you are passing in two
"nothing"s.

ie:

<%
strEmail = listings.Fields.Item("Email").Value
strWWW = listings.Fields.Item("WWW").Value
%>
<td valign="top"><%=GetContactDetails(strEmail, strWWW)%></td>

The function GetContactDetails() can be located anywhere in your code.

Also, I made a mistake with the function. Rewrite it like this:

<%
Function GetContactDetails( _
ByVal strEmail, _
ByVal strWWW _
)

If isNull(strWWW) then
GetContactDetails = "<a href=""mailto:""" & strEmail &
""">Email</a>"
Else
GetContactDetails = "<a href=""http://""" & strWWW & """>WWW</a>"
End If

End Function
%>

So, it checks strWWW. If that is NULL, then it returns the email address.
You may wish to put an additional check in the in case strEmail is *also*
NULL, in which case you might want to return "no contact details" or
something.

If strWWW is not NULL, then it returns the link.

Cheers
Ken


"John Pether" <john@<nospam>dotnetsites.net> wrote in message
news:ez**************@TK2MSFTNGP12.phx.gbl...
: ok, great thanks for your help. I had a few probs with the code, syntax
etc...but got through that....however nuthing is appearing on the page. I
have used the code below but even though there is an entry in the www field,
nothing is showing on the page.
:
: I also do not see how this would allow "www" to take precedent over
"email" if they both have data in the fields....
:
: Once again thanks for your help and I hope you/someone can help me get
this working:)
:
: <td valign="top"><%=GetContactDetails(strEmail, strWWW)%></td>
:
: <%
: strEmail = listings.Fields.Item("Email").Value
: strWWW = listings.Fields.Item("WWW").Value
: %>
: <%
: Function GetContactDetails( _
: ByVal strEmail, _
: ByVal strWWW _
: )
:
: If isNull(listings.Fields.Item("WWW")) then
: GetContactDetails = "<a href=""mailto:""" &
listings.Fields.Item("Email").Value & """>"
: Else
: GetContactDetails = "<a href=""http://""" &
listings.Fields.Item("WWW").Value & """>"
: End If
:
: End Function
: %>
:
: ************************************************** ********************
: Sent via Fuzzy Software @ http://www.fuzzysoftware.com/
: Comprehensive, categorised, searchable collection of links to ASP &
ASP.NET resources...
Jul 19 '05 #4
Great!!

Thanks for all your help, I've learnt loads:)

I have tried as you said to add another section to deal with to nulls but it gives an error.
I added another if statement:
If isNull(strWWW, strEmail) then
GetContactDetails = "No Internet Details"
End If

I presume from the error that you cannot pass two arguments to isNull, how should I do this?

John

************************************************** ********************
Sent via Fuzzy Software @ http://www.fuzzysoftware.com/
Comprehensive, categorised, searchable collection of links to ASP & ASP.NET resources...
Jul 19 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: theComputer7 | last post by:
I cut down the code to make this half way understandable... I have read Data Grid girls caution about over use of dynamic controls. I truly believe what I am doing requires dynamically inserted...
3
by: Chad THomas | last post by:
I have a data repeater controll on a page. in each row that is displayed, I would like to have an action column that has differnet links shown depending on certain criteria from the database. In...
2
by: Timothy V | last post by:
Hi, I have a RadioButton within a Repeater that i wish to assign an ID dynamically to the radiobutton. However, this won't allow me due to the following error:...
5
by: Matt Jensen | last post by:
Am I right in saying that you can't have a Radiobutton web control inside a repeater bound to a database datasource and (inline) dynamically set it's ID and text properties from the repeaters rows?...
3
by: Colin | last post by:
Hello, I can manage quite well in ASP but would like some advice in the best way to achieve dynamic layout in ASP.NET and still keep the page and code separate. Let's say I already have a...
1
by: Bobstar | last post by:
Hello Im trying to develop a nested repeatertemplate, Im trying to create a template in the following way: Repeater r = new Repeater(); r.ID = "Repeater0"; // r.HeaderTemplate = new...
7
by: | last post by:
I have what's probably a simple page lifecycle question related to dynamically evaluating values that are placed by a repeater and dynmically placing user controls that use those values. I'm...
0
by: simon | last post by:
hello, relatively new to .net, i'm using vb.net and the 2.0 .net platform I'm trying to display a grid that has a text box on the left in one cell (with a hidden ID), which will be associated...
3
by: s.bussing | last post by:
Hi, I have been reading for hours now, but I'm still not able to solve my problem, though a lot of people are struggling with something similar. On my page I have a nested repeater. In the inner...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.