Craig Gibbons' Lifeblog lifeblog://


DataList ItemDataBound e.Item.Visible = false doesn’t work

I came across a small problem today when trying to set items in a DataList to Visible = false in the ItemDataBound event. Quite simply, it just plain wasn't working. I did a bit of Googling and found several reported instances of this, but only one suggested any type of resolution. That forum thread can be found here:

Strangely, the problem only occurs when the RepeatLayout property of the DataList is set to Table. Change the RepeatLayout to Flow and the problem goes away.

Alternatively, Do something like this:

e.Item.CssClass = "hidden";

Then, add a CSS class "hidden" to your stylesheet:

.hidden {

Filed under: Tech Leave a comment
Comments (0) Trackbacks (0)

No comments yet.

Leave a comment

No trackbacks yet.