473,608 Members | 2,077 Online
Bytes | Software Development & Data Engineering Community
+ 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.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
Nov 19 '05 #1
2 2273
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.
--------------------------
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

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.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



Nov 19 '05 #3

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

Similar topics

11
4179
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 me an example of something hidden from the user?
17
2906
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 when the Poodle is upcast to the Dog (in its wildest dreams) it then says "bow wow" where the bernard always says "woof" (see code). Basically, it appears that I'm hiding the poodle's speak method from everything except the poodle. Why would I...
0
969
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 be able to move the pointers around, but that doesn't seem to be the case. I tried this: Dim oItem as DataListItem oItem = oList.Items(1) oList.Items(1) = oList.Items(2)
9
4972
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 hiding saves the day. I know there exists one, I'd just like to hear about it. thanks and have a nice day.
3
6562
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 foo( char const ) {} };
1
1241
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 - 1).DataItem, DataRowView).Row("id")) However, this gives me an error stating that the object cannot be found. What am I doing wrong? Thanks. -- Nathan Sokalski
17
2006
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 problem is that when i mouseover an element and then onmouseout it and then back again mouseovers that element before the timeout, the element still gets hidden so i put a flag=1 when i mouseover the element and flag=0 at mouseout and checked the value...
162
10187
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 prefix them with 2 underscores, but I hate prefixing my vars, I'd rather add a keyword before it. Python advertises himself as a full OOP language, but why does it miss one of the basic principles of OOP? Will it ever be added to python?
27
2760
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: ================ module.h ================ #ifndef __MODULE_HDR_INCLUDED__
0
8063
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8003
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8498
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8341
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6014
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5476
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3962
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4025
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1598
muto222
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.