ASP Question....

Jumpem

Lifer
Sep 21, 2000
10,757
3
81
Is there a way to do a conditional statement in an asp page? It's a simple problem really. I have a "student" type and a "volunteer" type. If the type equals 'student' I want the link to go to ViewStudent.aspx. If it equals "volunteer" I want the link to send them to ViewVolunteer.aspx. I just need to be able to have a basic if statement for the user type. Please help me out if you can, or point me to any good links.

Thanks!
 

edmicman

Golden Member
May 30, 2001
1,682
0
0
if varType="student" then
response.write "hyperlink text to student page"
else
response.write "hyperlink text to other page"
end if

wouldn't this work?
 

Jumpem

Lifer
Sep 21, 2000
10,757
3
81
It should if I can get the syntax right. The person that wrote this page was using repeaters and I am not familiar with them.:(
 

Jumpem

Lifer
Sep 21, 2000
10,757
3
81
I figured it out this morning. I'm doing it like this:

<a href='<%# DataBinder.Eval(Container.DataItem,"Type").Equals("Student") ? ("ViewStudent.aspx?" + "studentID=" + DataBinder.Eval(Container.DataItem, "ID")) : ("ViewVolunteer.aspx?" + "volunteerID=" + DataBinder.Eval(Container.DataItem, "ID"))%>'>
<%# DataBinder.Eval(Container.DataItem, "FirstName") %>
<%# DataBinder.Eval(Container.DataItem, "LastName") %>
</a>
 

GilletteCat

Member
Dec 28, 2001
181
0
0
Looks good. Your subject says ASP question, but it should say ASP.NET question :)
That was the reason for the first suggestion in this thread.
Repeater is a standard .NET control, and probably a popular one. It's better than DataGrid because it allows templates and very easy and nice formatting via styles. Also, you don't have to write any code to go through the recordset, since this control is called Repeater.