I did find that I can do the <div id=name visible=false runat="server"> . I
needed to do this instead of making each object invisible as the datalist
control has html table/tr/td code in it that would still be visible.
The problem is that if I use the div and make it invisible, I seem to lose
the other object forever. I tried to make the div visible (which works
fine), but the objects (grid, labels etc) are not there.
Here is the control tree from my trace.warn:
*************** *************** *************** *******
DataList1System .Web.UI.WebCont rols.DataList11 3976
DataList1:_ctl0 System.Web.UI.W ebControls.Data ListItem290
DataList1:_ctl0 :_ctl0System.We b.UI.LiteralCon trol100
DataList1:_ctl0 :dataListItemDi vSystem.Web.UI. HtmlControls.Ht mlGenericContro l032
DataList1:_ctl0 :_ctl1System.We b.UI.LiteralCon trol00
DataList1:_ctl0 :ExpandButtonSy stem.Web.UI.Web Controls.ImageB utton00
DataList1:_ctl0 :_ctl2System.We b.UI.LiteralCon trol00
DataList1:_ctl0 :CollapseButton System.Web.UI.W ebControls.Imag eButton00
DataList1:_ctl0 :_ctl3System.We b.UI.LiteralCon trol00
DataList1:_ctl0 :PositionIDSyst em.Web.UI.WebCo ntrols.Label032
DataList1:_ctl0 :_ctl4System.We b.UI.LiteralCon trol00
DataList1:_ctl0 :QuestionUnique System.Web.UI.W ebControls.Labe l028
DataList1:_ctl0 :_ctl5System.We b.UI.LiteralCon trol00
DataList1:_ctl0 :QuestionTypeSy stem.Web.UI.Web Controls.Label0 32
DataList1:_ctl0 :_ctl6System.We b.UI.LiteralCon trol00
DataList1:_ctl0 :QuestionSystem .Web.UI.WebCont rols.Label084
DataList1:_ctl0 :_ctl7System.We b.UI.LiteralCon trol00
DataList1:_ctl0 :DataGrid1Syste m.Web.UI.WebCon trols.DataGrid0 136
DataList1:_ctl0 :dataGridBrSyst em.Web.UI.HtmlC ontrols.HtmlGen ericControl00
DataList1:_ctl0 :_ctl8System.We b.UI.LiteralCon trol00
DataList1:_ctl0 :submitQuestion System.Web.UI.W ebControls.Butt on00
DataList1:_ctl0 :_ctl9System.We b.UI.LiteralCon trol00
DataList1:_ctl0 :_ctl10System.W eb.UI.LiteralCo ntrol190
DataList1:_ctl1 System.Web.UI.W ebControls.Data ListItem190
DataList1:_ctl1 :_ctl1System.We b.UI.LiteralCon trol100
DataList1:_ctl1 :_ctl0System.We b.UI.HtmlContro ls.HtmlGenericC ontrol00
DataList1:_ctl1 :_ctl2System.We b.UI.LiteralCon trol90
DataList1:_ctl2 System.Web.UI.W ebControls.Data ListItem290
DataList1:_ctl2 :_ctl0System.We b.UI.LiteralCon trol100
DataList1:_ctl2 :dataListItemDi vSystem.Web.UI. HtmlControls.Ht mlGenericContro l032
DataList1:_ctl2 :_ctl1System.We b.UI.LiteralCon trol00
DataList1:_ctl2 :ExpandButtonSy stem.Web.UI.Web Controls.ImageB utton00
DataList1:_ctl2 :_ctl2System.We b.UI.LiteralCon trol00
DataList1:_ctl2 :CollapseButton System.Web.UI.W ebControls.Imag eButton00
DataList1:_ctl2 :_ctl3System.We b.UI.LiteralCon trol00
DataList1:_ctl2 :PositionIDSyst em.Web.UI.WebCo ntrols.Label032
DataList1:_ctl2 :_ctl4System.We b.UI.LiteralCon trol00
DataList1:_ctl2 :QuestionUnique System.Web.UI.W ebControls.Labe l028
DataList1:_ctl2 :_ctl5System.We b.UI.LiteralCon trol00
DataList1:_ctl2 :QuestionTypeSy stem.Web.UI.Web Controls.Label0 32
DataList1:_ctl2 :_ctl6System.We b.UI.LiteralCon trol00
DataList1:_ctl2 :QuestionSystem .Web.UI.WebCont rols.Label060
DataList1:_ctl2 :_ctl7System.We b.UI.LiteralCon trol00
DataList1:_ctl2 :DataGrid1Syste m.Web.UI.WebCon trols.DataGrid0 136
DataList1:_ctl2 :dataGridBrSyst em.Web.UI.HtmlC ontrols.HtmlGen ericControl00
DataList1:_ctl2 :_ctl8System.We b.UI.LiteralCon trol00
DataList1:_ctl2 :submitQuestion System.Web.UI.W ebControls.Butt on00
DataList1:_ctl2 :_ctl9System.We b.UI.LiteralCon trol00
DataList1:_ctl2 :_ctl10System.W eb.UI.LiteralCo ntrol190
DataList1:_ctl3 System.Web.UI.W ebControls.Data ListItem190
DataList1:_ctl3 :_ctl1System.We b.UI.LiteralCon trol100
DataList1:_ctl3 :_ctl0System.We b.UI.HtmlContro ls.HtmlGenericC ontrol00
DataList1:_ctl3 :_ctl2System.We b.UI.LiteralCon trol90
*************** *************** *************** *************** *************** *******
Every other datalistitems show the controls and the other only show 3
controls.(I think because of the AlternateRow).
This is after I set all the div to visible=true.
So obviously this is not going to work.
It would have been so easy had MS property worked correctly.
Tom
"tshad" <ts**********@f tsolutions.com> wrote in message
news:%2******** ********@TK2MSF TNGP10.phx.gbl. ..
"Jc Morin" <mi************ ****@jcmorin.ne t> wrote in message
news:uC******** ******@TK2MSFTN GP09.phx.gbl... Hi Tom,
The visible property inherits from the Control object, this property is
usually used to hide completely a control.
Setting the property to every items seems logical to me also to hide/show
them but It seems that your right, it doesn't work...
However I found something that may interest you.
I've try this in the ItemDataBound methods:
e.Item.Parent.V isible = False
And the visible property seems to works.
Lets me know if that solve your problem.
Not sure how to make this work.
The databound event only happens once per row as the data comes in.
In my case,
I want to be able make the datalistitem visible and not visible depending
on the user. All the data is there already.
I tried to put a <div id="dataitem" runat="server"> around the data inside
the ItemTemplate, but got a compiler error trying that.
The only way I have been able to figure out how to do it is to make each
object in the datalist "not visible" and then make the ones in the
datalist I am dealing with visible (and of course the list that was
visible needs to be made invisible).
Would have been easier and cleaner to be able to use the visible field of
the datalistitem as MS documentation says you can.
Thanks,
Tom
--------------------------
Jean-Claude Morin, MCP
Software Developer
2k1Soft/kCentric, Canada
"tshad" <ts**********@f tsolutions.com> wrote in message
news:en******** ******@TK2MSFTN GP09.phx.gbl... I am trying to hide all my datalistitems, which contain labels,
textboxes
a datagrid, etc. I want to show each datalist item one at a time on the
page as the user pages through it.
I tried:
for each oItem as DataListItem in DataList1.Items
oItem.Visible = false
And that doesn't seem to work.
I can set the whole datalist.visibl e to false and it hides it fine.
Why doesn't the Datalistitem.vi sible = false work? It is supposed to be
a
property of the datalistitem.
Thanks,
Tom