Repeater Separator question

N

Nick Foster

I have a repeater I have bound to a custom collection of TicketLogEntries.
If a TicketLogEntry is marked as private and the user is not an
administrator, then the Item is hidden (code below).

The question is: if I set an item's or alteratingitem's Visible property to
False, can I also hide the accompanying Separator? It's a bit of a giveaway
that records are invisible if the separator is still showing :(


Private Sub rptrLog_ItemDataBound(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.RepeaterItemEventArgs) Handles rptrLog.ItemDataBound
If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType =
ListItemType.AlternatingItem Then
Dim bPrivate As Boolean = CType(e.Item.DataItem,
TicketLogEntry).IsPrivate
If bPrivate AndAlso HttpContext.Current.User.IsInRole("Administrator")
= False Then
e.Item.Visible = False
End If
End If
End Sub

Thanks,
Nick
 
M

marss

Nick Foster :
The question is: if I set an item's or alteratingitem's Visible property to
False, can I also hide the accompanying Separator? It's a bit of a giveaway
that records are invisible if the separator is still showing :(


Private hideSeparator As Boolean = False

Private Sub rptrLog_ItemDataBound(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.RepeaterItemEventArgs) Handles
rptrLog.ItemDataBound
If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType =
ListItemType.AlternatingItem Then
Dim bPrivate As Boolean = CType(e.Item.DataItem,
TicketLogEntry).IsPrivate
If bPrivate AndAlso
HttpContext.Current.User.IsInRole("Administrator") = False Then
e.Item.Visible = False
End If
hideSeparator = e.Item.Visible
End If
If e.Item.ItemType = ListItemType.Separator And hideSeparator Then
e.Item.Visible = False
End If
End Sub

Regards,
Mykola
http://marss.co.ua
 
N

Nick Foster

Mykola,

Thanks for pointing me in the right direction. One small change and it's
working great!

your line:
hideSeparator = e.Item.Visible

hid the separators for the visible items :) Using:

hideSeparator = (e.Item.Visible = False)

and everything is great.

Thanks again.
 

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

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top