repeater/hyperlink & dbNULL ??

F

fredda054

Hi everybody !

I have a little repeater/hyperlink issue I'm not sure how to solve.
I use a repeater to list subjects available at a specific school.
The datasource of this repeater is a dataset filled with info from a
SQL Server database.
All the subjects are displayed as hyperlinks, and when a user clicks a
subject it opens up a new beowser with the website specific to that
subject (ie the specific department website).

Everything is working just fine except if the URL field in the database
table is 'NULL'. then the new browser will just display the "page
cannot be displayed" message, which is pretty obvious.

What I want to do is to make a check if the specific item in the
dataset is 'null' and if so I want the user to be redirected to my
global "message page" just passing a querystring saying, "sorry, no
available url for the moment", or something like that.

I think I should use the ItemDataBound event but I'm not sure how to do
it. I've tried a few options but I can't get it to work.
Any help would be highly appreciated !

Thanks a lot !

I include the repeater code below just in case...
In the code behind I just set the datasource of the repeater and bind
it. Nothing else is going on there...

----------------------------------------------------------
<asp:repeater id="rptSubjects" runat="server">
<ItemTemplate>
<table>
<tr>
<td>
<asp:HyperLink NavigateUrl='<%# "http://" &
Container.DataItem("Dep_WebsiteURL") %>' text='<%#
Container.DataItem("SubjectName") %>' Runat="server" Target="_blank"
ID="Hyperlink1" />
</td>
</tr>
</table>
</ItemTemplate>
</asp:repeater>
-----------------------------------------------------------
 

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,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top