473,480 Members | 3,017 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Hiding datalistitems

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.visible to false and it hides it fine.

Why doesn't the Datalistitem.visible = false work? It is supposed to be a
property of the datalistitem.

Thanks,

Tom
Nov 19 '05 #1
2 2264
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.Visible = False

And the visible property seems to works.

Lets me know if that solve your problem.
--------------------------
Jean-Claude Morin, MCP
Software Developer
2k1Soft/kCentric, Canada
"tshad" <ts**********@ftsolutions.com> wrote in message
news:en**************@TK2MSFTNGP09.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.visible to false and it hides it fine.

Why doesn't the Datalistitem.visible = false work? It is supposed to be a
property of the datalistitem.

Thanks,

Tom

Nov 19 '05 #2
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.WebControls.DataList113976
DataList1:_ctl0System.Web.UI.WebControls.DataListI tem290
DataList1:_ctl0:_ctl0System.Web.UI.LiteralControl1 00
DataList1:_ctl0:dataListItemDivSystem.Web.UI.HtmlC ontrols.HtmlGenericControl032
DataList1:_ctl0:_ctl1System.Web.UI.LiteralControl0 0
DataList1:_ctl0:ExpandButtonSystem.Web.UI.WebContr ols.ImageButton00
DataList1:_ctl0:_ctl2System.Web.UI.LiteralControl0 0
DataList1:_ctl0:CollapseButtonSystem.Web.UI.WebCon trols.ImageButton00
DataList1:_ctl0:_ctl3System.Web.UI.LiteralControl0 0
DataList1:_ctl0:PositionIDSystem.Web.UI.WebControl s.Label032
DataList1:_ctl0:_ctl4System.Web.UI.LiteralControl0 0
DataList1:_ctl0:QuestionUniqueSystem.Web.UI.WebCon trols.Label028
DataList1:_ctl0:_ctl5System.Web.UI.LiteralControl0 0
DataList1:_ctl0:QuestionTypeSystem.Web.UI.WebContr ols.Label032
DataList1:_ctl0:_ctl6System.Web.UI.LiteralControl0 0
DataList1:_ctl0:QuestionSystem.Web.UI.WebControls. Label084
DataList1:_ctl0:_ctl7System.Web.UI.LiteralControl0 0
DataList1:_ctl0:DataGrid1System.Web.UI.WebControls .DataGrid0136
DataList1:_ctl0:dataGridBrSystem.Web.UI.HtmlContro ls.HtmlGenericControl00
DataList1:_ctl0:_ctl8System.Web.UI.LiteralControl0 0
DataList1:_ctl0:submitQuestionSystem.Web.UI.WebCon trols.Button00
DataList1:_ctl0:_ctl9System.Web.UI.LiteralControl0 0
DataList1:_ctl0:_ctl10System.Web.UI.LiteralControl 190
DataList1:_ctl1System.Web.UI.WebControls.DataListI tem190
DataList1:_ctl1:_ctl1System.Web.UI.LiteralControl1 00
DataList1:_ctl1:_ctl0System.Web.UI.HtmlControls.Ht mlGenericControl00
DataList1:_ctl1:_ctl2System.Web.UI.LiteralControl9 0
DataList1:_ctl2System.Web.UI.WebControls.DataListI tem290
DataList1:_ctl2:_ctl0System.Web.UI.LiteralControl1 00
DataList1:_ctl2:dataListItemDivSystem.Web.UI.HtmlC ontrols.HtmlGenericControl032
DataList1:_ctl2:_ctl1System.Web.UI.LiteralControl0 0
DataList1:_ctl2:ExpandButtonSystem.Web.UI.WebContr ols.ImageButton00
DataList1:_ctl2:_ctl2System.Web.UI.LiteralControl0 0
DataList1:_ctl2:CollapseButtonSystem.Web.UI.WebCon trols.ImageButton00
DataList1:_ctl2:_ctl3System.Web.UI.LiteralControl0 0
DataList1:_ctl2:PositionIDSystem.Web.UI.WebControl s.Label032
DataList1:_ctl2:_ctl4System.Web.UI.LiteralControl0 0
DataList1:_ctl2:QuestionUniqueSystem.Web.UI.WebCon trols.Label028
DataList1:_ctl2:_ctl5System.Web.UI.LiteralControl0 0
DataList1:_ctl2:QuestionTypeSystem.Web.UI.WebContr ols.Label032
DataList1:_ctl2:_ctl6System.Web.UI.LiteralControl0 0
DataList1:_ctl2:QuestionSystem.Web.UI.WebControls. Label060
DataList1:_ctl2:_ctl7System.Web.UI.LiteralControl0 0
DataList1:_ctl2:DataGrid1System.Web.UI.WebControls .DataGrid0136
DataList1:_ctl2:dataGridBrSystem.Web.UI.HtmlContro ls.HtmlGenericControl00
DataList1:_ctl2:_ctl8System.Web.UI.LiteralControl0 0
DataList1:_ctl2:submitQuestionSystem.Web.UI.WebCon trols.Button00
DataList1:_ctl2:_ctl9System.Web.UI.LiteralControl0 0
DataList1:_ctl2:_ctl10System.Web.UI.LiteralControl 190
DataList1:_ctl3System.Web.UI.WebControls.DataListI tem190
DataList1:_ctl3:_ctl1System.Web.UI.LiteralControl1 00
DataList1:_ctl3:_ctl0System.Web.UI.HtmlControls.Ht mlGenericControl00
DataList1:_ctl3:_ctl2System.Web.UI.LiteralControl9 0
************************************************** ********************************

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**********@ftsolutions.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
"Jc Morin" <mi****************@jcmorin.net> wrote in message
news:uC**************@TK2MSFTNGP09.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.Visible = 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**********@ftsolutions.com> wrote in message
news:en**************@TK2MSFTNGP09.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.visible to false and it hides it fine.

Why doesn't the Datalistitem.visible = false work? It is supposed to be
a
property of the datalistitem.

Thanks,

Tom



Nov 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
4167
by: Lorenzo Villari | last post by:
I premise I don't know C++ well but... I wondered what is this data hiding thing... I mean, if I can look at the header (and i need it beacuse of the class), then what's hidden? Can someone give...
17
2894
by: Bob Weiner | last post by:
What is the purpose of hiding intead of overriding a method? I have googled the question but haven't found anything that makes any sense of it. In the code below, the only difference is that...
0
959
by: tshad | last post by:
I want to be able to allow my users to move DataListItems up and down without going back to the database. I assumed that your DataListItems were only pointers ( I am probably wrong here) and would...
9
4960
by: bob | last post by:
Hi, I know there exists a good reason why the designers of c++ decided that function hiding should exist. But I don't know why. Can anybody provide a good reason/example of a case where function...
3
6551
by: Nicolas Castagne | last post by:
Hi all, I have been wondering for a while why function hiding (in a derived class) exists in C++, e.g. why when writing class Base { void foo( int ) {} }; class Derived: public Base { void...
1
1234
by: Nathan Sokalski | last post by:
I am trying to access the DataItem of other DataListItems in a DataList of mine from within the ItemDataBound. The code I am currently using is: CStr(CType(Me.datMain.Items(e.Item.ItemIndex -...
17
1978
by: rohitchawla | last post by:
i am trying to show and hide a div when onmouseover and onmouseover another div element. i am setting a setTimeout duration on onmouseout to delay the hiding of div for around two second The...
162
10057
by: Sh4wn | last post by:
Hi, first, python is one of my fav languages, and i'll definitely keep developing with it. But, there's 1 one thing what I -really- miss: data hiding. I know member vars are private when you...
27
2739
by: matt | last post by:
Hello group, I'm trying to become familiar with the information hiding design rules, and I have a lot (3) of questions for all you experts. AFAIK, a generic module has 2 files: ...
0
7055
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
6920
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7060
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
6760
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5365
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4799
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4501
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
1311
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
572
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.