Visibility control of Panel control and its affect on data controls

Thought I would toss this out here this morning and perhaps someone else had run across the same issue and had found a good way to accomplish what I want. First let me state what I'm attempting to do and the problem that I've run into.

 GridView1 has a collection of rows in a SQL table that I want to present to the user. I've provided them the options of sorting and selecting only from the GridView control. 

Orgionally, I had created a detail view that was being presented in Edit mode and then customized the layout of the edit item template to suit my needs.  The only difficulty I ran into was being able to have dropdownlist's with values from the database being the selected value and updating back to the table when done.  I found lots of dropdownlist examples but none were inside a detailview control, databound to datasource B, select value from datasource A and updating back to datasource A.

Okay, Fine!  So, I figured I would simply do things a bit more manually; put labels, textbox's, and dropdownlist's in a table layout and populate it with values from the selected row in the gridview, allow the user to change things around and then update it back to the table. Piece of pie!.... Well, yes it was simple enought.... BUT!!!

I'd place this table and its collection of labels, textboxes, and dropdownlists in a Panel control so I could keep it out of view while the user was selecting a row in the GridView to edit.  During inital building of the pannel and the underlying controls I had left visibility on just for simplicity.  As soon as I changed the initial state of the Panel control and tested I found that the databound dropdownlist's in the Panel no longer function and were returning NULL values to the list selection.

Turn on visibiliy and the controls worked fine.

Further expanding on this with a little extra observation...

Before turning off the inital visibility state of the Panel control, I did have settings in the code to turn on and off visibility.  This was/is working fine. In other words, I was able progamiticly to turn off visibility and turn it back on again, so long as the inital state of visibility for the panel was visible. I would:

- Enter the page, see the panel control on the top with the gridview control below
- Select a row to edit and the controls in the panel would be populated with the values from the selected row
- Click on the Update or Cancel buttons and the action would be taken as selected and the Panel control would now be hidden from view.
- Then select a different row and see the Panel reappear with the controls populated from the newly selected row.

So.... question is... What is the difference in setting the visibility of the Panel control to 'False' in intial page load, versus turning off visibiliy in code after intial page load?  How would you suggest getting around  this issue.  It is just sloppy to leave the panel up there with no data in it while the user is expected to select a row.  At the same time, the detail view provides the 'keep it out of sight till needed' methodology, but lacks the flexibility I want for my data controls in the form. 

Your suggestions and comments are greatly appreciated!


6/21/2007 12:06:22 PM 93655 articles. 6 followers. Follow

1 Replies

Similar Articles

[PageSpeed] 50
Get it on Google Play
Get it on Apple App Store

 Instead of setting Visible="false" hide the panel using CSS. When you set the visibility to hidden on the server, the control is not rendered into the page and so the values are null on postback.

You could use style="visibility:hidden"  or  style="display:none" to achieve what you are looking for.


Dont forget to click "Mark as Answer" on the post that helped you.
6/21/2007 2:38:45 PM

Similar Artilces:

Controlling web control instances on Web Form
I have created a composite control, extending functionality of the Hidden Control. However, I would like to prevent the user from adding this control to the page multiple times. I only want one instance of the control on the Web Form. What setting in my project to I adjust to enable this functionality? I can not find it in any of the books that I have referenced. Is this a setting or is this code that has to be added to the inheriting class. Looks like there is no standard apporach. But I'd consider using static field to count number of created objects and throw exception if second object ...

controlling an object in a web control from the page the web control is placed in
I have created a web control in that has an image button and an image. when it loads the image button is visible and the image is not. I want to be able from the page which "includes" the web control to set the image button to invisible and the image to visible. When I tried this, the main page didn't recognise the image button or the image (both < asp: objects). help would be gratefully appreciated. oh yeah, it's inline code so any code behind stuff will just confuse me ;) Some code please.-- Justin Lovell...

How to access individual controls from a form containing the web user control containing those controls
 Below is a block of code in my .aspx form named default.aspx. In this form I load a web user control. I then add it to a place holder control.(Lines 3 and 4 below) So how do I access the individual controls in my web user control? I want to set the properties on those controls, but I am baffled as to how to access the control. For example I have a text label control named "label3". How do I access this control. Because for example, under certain situations I want to hide that control. ( Label3.Visible = false;)  1    if(!Page.IsPostBack) 2&nb...

Web control in web control
Hi,There are two simple web user controls A and B, where B contains A. They just display the bunch of text boxes, so I do not need them even in tool pane. They sit in the same project next to web form.I noticed that web user control put on ASPX page does not appear in code behind, but if I create it with protected keyword and name being exactly the same as id it works fine. I can access such a web control from code behind and see the value assigned in IE. The problem is that the same routine does work for my A web control in B. When I assign the value IE, I keep getting null reference. ...

UpdatePanel within a web user control resets data of controls outside the user control
Hello, I have a usercontrol on my page which displays a running marquee text. It makes use of an UpdatePanel (within the user control) to refresh the marquee text (within the updatepanel) at periodic intervals. For this I added a timer control and its tick event as an async postback trigger for the UpdatePanel. I have a lot of textboxes and dropdown list boxes (all with runat=server) on the page outside the above user control. These are also contained in different UpdatePanels. Problem is, when the user control does a postback to refresh the marquee text, it causes some of...

how to call controls of web control form in coding of other forms?
hello everyone i have one problem i have created one webcontrol shoppingcart in which there are two labels one of qty and other of amt which are initially enable =falsenow on other page(aspx page) i have one txtbox of qty as txtqty i want tat as soon as user enters qty txtqty and clicks on add cart button it shd be display d value in lblqty of web control shopping cart make sure i m using datalist on aspx page so give me suggestions on tat basis and my coding is in vb. plz give ur suggestions as fast as possible. Neeti what do you mean by webcontrol.... it this user control or normal ...

How to visible an control below the control
hi friends i Need all your help In a form i placed an button. On the click event of button i returned an function to show an calendar And i placed dropdown control below the button. When i click the button the was calendar shown on that time dropdown was invisible What i want is to show the calendar as well as the dropdown control in the form.  waiting for you reply thanks santhosh Inside the click event: dropdownlist1.visible="true"David WierMCP/ - where to look first!Please Vote for ASPNet101 - 'Best Community Resource'!Contro...

access controls on web user control x from web user control Y
I have 2 web users controls in a page and I would like to get or set the selected values of a few dropdown boxes on web user control X from web user control Y and I also would like to know how to access functions that are on a web user control X from a web user control Y, is this possible? How can I do it? User can access and set the values of the User Control from .aspx page through properties,using javascript and in code-behind of aspx page.The details of it are shown below Using PropertiesIf the Sample.ascx control has two textboxes and submit button.You can access the valu...

Setting a panel control's visibility and it's affect in nested controls.
I am trying to debug a page using the panel control.  The code in the final submission of the form has logic to get data from a dropdown based on the control's visibility.  If the control's visibility is set to true, the the data is retrieved and sent to the database.The problem appears to be the dropdown control's visibility is set to false when it should not.  The dropdown is nested in a panel control.  While doing a trace, it appears when a panel control's visibility is set to false, the visibility for all controls nested under this panel are set to false as well.You'r...

Problem in accessing web form data in user controls when create user control dynamically
HI. I have a problem using web user control. I designed a user control named NewsForm. This user control contains some web form elements like <asp:textbox>. When I add it in an .ASPX page, all things may be true. I can know which user filles in textbox (for example and other controls) <%@ Register TagPrefix="uc1" TagName="NewsForm" Src="NewsForm.ascx" %> and <UC1:NewsForm id="newsForm" runat="server"></UC1:NewsForm> But when i create it in code behined dynamically, however user control has web form controls but their value are blank for example //aspx co...

Custom Control within a Control Control
I am developing a custom controls that will render headers for different web sites. Within these controls, I want to place another custom control that will change the language. I created the language control and had it implement IPostBackDataHandler. This control works fine if I drag it on a new web form, but if I tell a header custom control to render it problems occur. The Language Selector custom control does not have a Page member anymore and the event handlers do not work. Does anyone have any experience with doing something similiar? Anyone have any suggestions? Thanks, ...

How do I control one control from another control?
I have a page page1.aspx which is within a master page. On page I have a table with two cells. Within each cell I have placed two controls (ascx) that I have developed. Now I'd like to be able to get these two controls to interact. One needs to update the other. One has some search criteria that the other one needs to update its gridview. One needs to make the other visible/not visible at certain times. Out of the box neither control can see each other at all. Is there a good article or someplace I can find some information on how to do this? Information Technolo...

Use Web Control In a Web Control
Is this possible?I am working with an aspx page that consists of many different web controls.One of the web controls contains search criteria.  One of the criteria is a date range where I am trying to add a popup calendar --> which is another web controlCan I register the popupcaledar control on the questionaire control?  I have tried, but nothing seems to be registered.Any ideas will GREATLY help.Relax and have some Home Brew!Prosecute the Owner - Don't PERSECUTE the Breed!Breed Specific Legislation targets the WRONG end of the LEASH! Without seeing your code we can'...

web controls and web user control
i have a problem in a web form , I have a webform that contains a web user control which in turn contains a html input form ,the web control events don't fire up ,When I click button ,no effect ,I don't know what is the effect of the html form which is in the web user control on the web controls in the web form ?? can any one help me the web control event should be handle in the code behind page, is the event handler for the button you are clicking registered? You can try double clicking the button, should give you the default btn_click event handler in code behind. Also, make ...

Web resources about - Visibility control of Panel control and its affect on data controls -

High-visibility clothing - Wikipedia, the free encyclopedia
High-visibility clothing , a type of personal protective equipment (PPE), is any clothing worn that has highly reflective properties or a colour ...

Facebook Is Testing Advanced Chat Visibility Settings
Facebook is testing new advanced chat settings that allow users to limit visibility to individuals or lists of friends.

Giving People More Visibility and Control
Giving People More Visibility and Control

NSW to roll out new high-visibility mobile speed camera units
... advice from the NSW Roads Minister Duncan Gay who has announced measures to draw attention to mobile speed cameras, including new high-visibility ...

High visibility clothing for females developed by Queensland woman
While they might be getting good salaries, women in the mining industry haven't had good options when it comes to their work uniforms.

Cash visibility tops list in first Asia-Pacific treasury report
Improving cash visibility is the top priority for treasury departments across the Asia-Pacific yet technology adoption remains inadequate, according ...

Government's poor visibility over gay marriage debate
The gay marriage issue is causing some confusion within the Abbott government. Perhaps we should ask the fashion designers for their thoughts. ...

High-visibility clothing won't help cyclists
High-visibility clothing does not deter drivers from dangerously overtaking cyclists on shared roadways, new research has found.

Nenshi proclaims Trans Day of Visibility
Mayor Naheed Nenshi proclaimed Sunday as Trans Day of Visibility in Calgary, while Edmonton Mayor Stephen Mandel has announced that March 31 ...

Resources last updated: 1/2/2016 11:44:52 PM