Repeater - hyperlink

  • Thread starter Thread starter fredda054
  • Start date Start date
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
 
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
 
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
 
Back
Top