Repeater - hyperlink

F

fredda054

Hi everybody !
I need some advice about a repeater...
I have a repeater on a website displaying a list of hyperlinks. The
url's of these hyperlinks are all stored in a database. everything's
working just fine except if the url field in the database table is
'null'. Is there an easy way to make this check, to see if the value is
null and if so, display some information text instead of just
displaying a page with "The page cannot be displayed" message on it ?
How can I make conditions like 'if-else' within a repeater ?
i'm pretty new to .net so i would appreciate all help i can get...
Thanks

Fredrik
 
E

Eliyahu Goldin

Fredrik,

The most flexible way is to handle ItemDataBound event for the repeater. In
the event handler you get access to every item. You can check/set item
properties as you wish.

Eliyahu
 
F

fredda054

Thanks Eliyahu !
I thought I'd had to do it through event handling somehow.
I'm just not sure how to do it. Could anyone show me some code
examples. The datasource of the repeater is a dataset with a name and a
URL field. so, how do i access each item and do the check?

i guess it has to be something like this:
but what would be the more exact code?


Private Sub rptSubjects_ItemDataBound(ByVal.......
If IsDBNull(e.Item.DataItem) Then
show info message
else
'if there is a url in the DB field for this item
use correct URLfield value
End If
End Sub
 

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

Top