PC Review


Reply
Thread Tools Rate Thread

Adding controls dynamically problem.

 
 
=?Utf-8?B?UHVuaXNoZXI=?=
Guest
Posts: n/a
 
      11th Jan 2005
I'm adding checkbox controls to a table dynamically when the form loads for
the first time. When a postback occurs, the controls are not maintained in
the table. How do I get them to retain without having re-add them again.
 
Reply With Quote
 
 
 
 
Nicholas Paldino [.NET/C# MVP]
Guest
Posts: n/a
 
      11th Jan 2005
Punisher,

You have to re-add them again. If you don't, then how is it supposed to
know how to render it? ASP.NET page handlers don't retain state. Rather,
the state is retained through the viewstate, and the state is reconstructed
in the Page. Since the table control doesn't have any viewstate, it can't
retain whether or not you added controls.

You will have to re-add the controls again.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (E-Mail Removed)

"Punisher" <(E-Mail Removed)> wrote in message
news:B08CD87C-2CBB-4054-907E-(E-Mail Removed)...
> I'm adding checkbox controls to a table dynamically when the form loads
> for
> the first time. When a postback occurs, the controls are not maintained in
> the table. How do I get them to retain without having re-add them again.



 
Reply With Quote
 
=?Utf-8?B?UHVuaXNoZXI=?=
Guest
Posts: n/a
 
      11th Jan 2005
I thought when you do a postback, it retains the controls on the page. It's
not like a refresh is it? I could understand if it was, but that's not what
I'm wanting to do. I'm wanting to submit a page and then get the values out
of the checkboxes that was added dynamically.

How else can I can get the values from the dynamic added checkboxes?

"Nicholas Paldino [.NET/C# MVP]" wrote:

> Punisher,
>
> You have to re-add them again. If you don't, then how is it supposed to
> know how to render it? ASP.NET page handlers don't retain state. Rather,
> the state is retained through the viewstate, and the state is reconstructed
> in the Page. Since the table control doesn't have any viewstate, it can't
> retain whether or not you added controls.
>
> You will have to re-add the controls again.
>
> Hope this helps.
>
>
> --
> - Nicholas Paldino [.NET/C# MVP]
> - (E-Mail Removed)
>
> "Punisher" <(E-Mail Removed)> wrote in message
> news:B08CD87C-2CBB-4054-907E-(E-Mail Removed)...
> > I'm adding checkbox controls to a table dynamically when the form loads
> > for
> > the first time. When a postback occurs, the controls are not maintained in
> > the table. How do I get them to retain without having re-add them again.

>
>
>

 
Reply With Quote
 
=?Utf-8?B?UHVuaXNoZXI=?=
Guest
Posts: n/a
 
      11th Jan 2005
Disregard, I'm using a CheckBoxList and it's doing what I want now.

"Nicholas Paldino [.NET/C# MVP]" wrote:

> Punisher,
>
> You have to re-add them again. If you don't, then how is it supposed to
> know how to render it? ASP.NET page handlers don't retain state. Rather,
> the state is retained through the viewstate, and the state is reconstructed
> in the Page. Since the table control doesn't have any viewstate, it can't
> retain whether or not you added controls.
>
> You will have to re-add the controls again.
>
> Hope this helps.
>
>
> --
> - Nicholas Paldino [.NET/C# MVP]
> - (E-Mail Removed)
>
> "Punisher" <(E-Mail Removed)> wrote in message
> news:B08CD87C-2CBB-4054-907E-(E-Mail Removed)...
> > I'm adding checkbox controls to a table dynamically when the form loads
> > for
> > the first time. When a postback occurs, the controls are not maintained in
> > the table. How do I get them to retain without having re-add them again.

>
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
dynamically adding controls Jeff Microsoft ASP .NET 1 5th Oct 2006 03:09 PM
About Adding controls dynamically crazyjh Microsoft VB .NET 6 7th Aug 2006 12:08 PM
Dynamically Adding Controls Nathan Sokalski Microsoft ASP .NET 6 14th May 2005 01:34 AM
Dynamically Adding Controls Sandeep Microsoft ASP .NET 4 13th Jul 2004 10:12 AM
Dynamically adding controls at runtime - event problem Uzi Baruch Microsoft ASP .NET 0 17th Dec 2003 10:05 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:36 AM.