473,387 Members | 1,757 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,387 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 1660
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: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.