473,394 Members | 1,752 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Dynamic controls


Hi,

I am building a web form with dynamic controls. Some need to be visible and some not. When clicking on a button, all controls become visible. I have used code behind to do that, but when I set the value of a control (ie. label) and then click the button to show all controls, these value are lost. Should I use ViewState and save the state of each single control? Or is that a better method? Any resouce or sample would be highly appreciated.

Thanks
Mike
Nov 18 '05 #1
4 1662
The ViewState should intrinsically hold the set values, unless somewhere in the process (Page_Load, etc.) they are getting re-loaded with blank text.

"Mike" wrote:

Hi,

I am building a web form with dynamic controls. Some need to be visible and some not. When clicking on a button, all controls become visible. I have used code behind to do that, but when I set the value of a control (ie. label) and then click the button to show all controls, these value are lost. Should I use ViewState and save the state of each single control? Or is that a better method? Any resouce or sample would be highly appreciated.

Thanks
Mike

Nov 18 '05 #2
You might want to check out Denis Bauer's free DynamicControlsPlaceholder
control that seems to do what you need:

It "behaves like a placeholder but additionally handles recreating dynamic
controls on subsequent requests."

http://www.denisbauer.com/ASPNETCont...aceholder.aspx

"Mike" <no****@nospam.com> wrote in message
news:%2***************@TK2MSFTNGP12.phx.gbl...

Hi,

I am building a web form with dynamic controls. Some need to be visible and
some not. When clicking on a button, all controls become visible. I have
used code behind to do that, but when I set the value of a control (ie.
label) and then click the button to show all controls, these value are lost.
Should I use ViewState and save the state of each single control? Or is that
a better method? Any resouce or sample would be highly appreciated.

Thanks
Mike
Nov 18 '05 #3
Check out this article to know how to maintain viewstate in dynamically created controls,
http://www.codeproject.com/aspnet/retainingstate.asp

--
Saravana
Microsoft MVP - ASP.NET
www.extremeexperts.com

"Mike" <no****@nospam.com> wrote in message news:#s*************@TK2MSFTNGP12.phx.gbl...

Hi,

I am building a web form with dynamic controls. Some need to be visible and some not. When clicking on a button, all controls become visible. I have used code behind to do that, but when I set the value of a control (ie. label) and then click the button to show all controls, these value are lost. Should I use ViewState and save the state of each single control? Or is that a better method? Any resouce or sample would be highly appreciated.

Thanks
Mike
Nov 18 '05 #4
Mike
You have to be careful when setting the value, because the button click event happens after the pageload event and as David says the value might be set to blank on page load.
--
Ibrahim

"David Coe, MCAD" wrote:
The ViewState should intrinsically hold the set values, unless somewhere in the process (Page_Load, etc.) they are getting re-loaded with blank text.

"Mike" wrote:

Hi,

I am building a web form with dynamic controls. Some need to be visible and some not. When clicking on a button, all controls become visible. I have used code behind to do that, but when I set the value of a control (ie. label) and then click the button to show all controls, these value are lost. Should I use ViewState and save the state of each single control? Or is that a better method? Any resouce or sample would be highly appreciated.

Thanks
Mike

Nov 18 '05 #5

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

Similar topics

1
by: Will | last post by:
Hi all. I'm learning VB.Net and am developing a WinForms app. I'm trying to make an app that I will use to scan in one or more than on image. I want to use a tabbed interface to hold each image....
2
by: theComputer7 | last post by:
I cut down the code to make this half way understandable... I have read Data Grid girls caution about over use of dynamic controls. I truly believe what I am doing requires dynamically inserted...
3
by: Leo J. Hart IV | last post by:
OK, here's another question for the experts: I am building a multi-step (3 steps actually) form using a panel for each step and hiding/displaying the appropriate panel/panels depending on which...
0
by: pbb | last post by:
I have a web page on which I dynamically create controls based on the selection a user makes from a dropdownlist (this ddl is not dynamic). Depending on the user's selection, the controls could be...
1
by: Diffident | last post by:
Hello All, I am trying to add dynamic controls onto my page and here is how I am doing that. I have a page which has a button called as "AddMoreControls" and in this button's event handler I...
9
by: Tarscher | last post by:
hi all, I have this seemingly simple problem. I have lost a lot of time on it though. When a user selects a value from a dropdownlist (static control) a dynamic control is generated. I have...
0
by: Eniac | last post by:
Hi, I've been working on a custom user control that needs to be modified and the validation is causing me headaches. The control used to generate a table of 4 rows x 7 columns to display all...
1
by: MaryamSh | last post by:
Hi, I am creating a Dynamic Search in my application. I create a user control and in Page_load event I create a dynamic dropdownlist and 2 dynamic button (Add,Remove) By pressing Add button...
0
by: MaryamSh | last post by:
Create Dynamic Dropdownlist Controls and related event -------------------------------------------------------------------------------- Hi, I am creating a Dynamic Search in my application. I...
2
by: englishman69 | last post by:
Hello, I have been banging my head against this one for a while... Searches online have revealed many different proposals for correcting my issue but none that I can follow! My basic situation...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
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,...
0
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...

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.