Question

I have a Repeater element in my .aspx file that calls a bind sub in my CodeBehind on my OnItemDataBound event, similar to this:

Sub SomeRepeaterBinder(ByVal sender As Object, ByVal e As RepeaterItemEventArgs)
    (code binding data to repeater form objects goes here)
    :
    (etc.)

For the most part, it works great, but here's the problem I'm trying to solve: if there is no data, I want it to either (1) hide the repeater item, or (2) exit the sub completely (or maybe both).

In order to do that, I need to know whether or not any data exists in my Repeater item. And despite reading loads of documentation about RepeaterItemEventArgs properties (and running lots of debuggers), I haven't been able to figure out the correct syntax.

Can someone help me out with this? I'm hoping this is an easy question with an easy answer.

Note: my data source is XML. My form objects and my Repeater data source have XPaths assigned to them. I'm working with VB.

Thanks in advance . . .

Était-ce utile?

La solution

I don't know if this is the best answer for this, but here's how I got it to work.

I didn't use e.Item.DataItem at all. I took the XML data source for my repeater and used selectSingleNode (using the data source XPath) to return my value. If the resulting string is empty, I hide the row.

However, if anyone has a more elegant or robust answer, I'm all ears.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top