-2

How do you check in ascx if a repeater block is null/shows no values? I am displaying its content with Container.DataItem if it helps. Other actions will essentially depend on this condition. Thanks

Halle
  • 67
  • 8

1 Answers1

0

Depending on what you actually want to achieve you could check the following:

  • repeater.DataSource == null
    when there is no data source, then there won't be any items
  • repeater.Items
    Filter the items for ItemType ListItemType.Item or ListItemType.AlternatingItem to see whether there are any items bound.
  • You can also access the repeater itself from the ItemTemplate (navigate Container.Parent and cast then) or from codebehind like here Access Parent Repeaters DataItem Property
Community
  • 1
  • 1
Silvos
  • 165
  • 6