By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,257 Members | 928 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,257 IT Pros & Developers. It's quick & easy.

How to retain dynamically created web server control - help !!

P: n/a
Hello All,

I am programmatically building a table on my web page with one row and
two columns. The first column contains a web server checkbox
dynamically created and the second column simply contains text of
whatever I put in. This is running fine. If I check the checkbox, how
would I check if this checkbox is checked or not during postback? The
dynamically
created checkbox seems to have disappeared during postback.

Thanks in advance.

May 1 '06 #1
Share this Question
Share on Google+
4 Replies


P: n/a
If you create a control programmatically, then when the page is reloaded you
must re-create it. If enableViewState is true and the id of the control is
the same, then it will be able to hook back up with its ViewState.
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"sy********@gmail.com" wrote:
Hello All,

I am programmatically building a table on my web page with one row and
two columns. The first column contains a web server checkbox
dynamically created and the second column simply contains text of
whatever I put in. This is running fine. If I check the checkbox, how
would I check if this checkbox is checked or not during postback? The
dynamically
created checkbox seems to have disappeared during postback.

Thanks in advance.

May 1 '06 #2

P: n/a
Thanks for responding. Do you have some references / links where I can
take a look at some examples of how this is done?

Peter wrote:
If you create a control programmatically, then when the page is reloaded you
must re-create it. If enableViewState is true and the id of the control is
the same, then it will be able to hook back up with its ViewState.
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"sy********@gmail.com" wrote:
Hello All,

I am programmatically building a table on my web page with one row and
two columns. The first column contains a web server checkbox
dynamically created and the second column simply contains text of
whatever I put in. This is running fine. If I check the checkbox, how
would I check if this checkbox is checked or not during postback? The
dynamically
created checkbox seems to have disappeared during postback.

Thanks in advance.


May 2 '06 #3

P: n/a
Got this to work. Thanks for the info.

sy********@gmail.com wrote:
Thanks for responding. Do you have some references / links where I can
take a look at some examples of how this is done?

Peter wrote:
If you create a control programmatically, then when the page is reloaded you
must re-create it. If enableViewState is true and the id of the control is
the same, then it will be able to hook back up with its ViewState.
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"sy********@gmail.com" wrote:
Hello All,

I am programmatically building a table on my web page with one row and
two columns. The first column contains a web server checkbox
dynamically created and the second column simply contains text of
whatever I put in. This is running fine. If I check the checkbox, how
would I check if this checkbox is checked or not during postback? The
dynamically
created checkbox seems to have disappeared during postback.

Thanks in advance.


May 2 '06 #4

P: n/a
I thought I had it working but not quite. When I enumerate through my
Repeater and evaluate which checkbox is checked, it always comes back
as being not checked on every row. Here's excerpt the code:

For Each rpItem In ViewRepeater.Items
chkRespFlag = CType(rpItem.FindControl("chkSel"), CheckBox)
If Not IsNothing(chkRespFlag) then
If chkRespFlag.Checked Then
intSelected += 1
Else
intNotSelected += 1
End If
End If
Next

My intSelected is always = 0. When I do a "View Source" on the brower,
I do see some of the rows do have chkSel.Checked = "Checked". Yet,
when I evaluate, it is telling they are not checked. Can someone
explain this?

Thanks.
sy********@gmail.com wrote:
Got this to work. Thanks for the info.

sy********@gmail.com wrote:
Thanks for responding. Do you have some references / links where I can
take a look at some examples of how this is done?

Peter wrote:
If you create a control programmatically, then when the page is reloaded you
must re-create it. If enableViewState is true and the id of the control is
the same, then it will be able to hook back up with its ViewState.
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"sy********@gmail.com" wrote:

> Hello All,
>
> I am programmatically building a table on my web page with one row and
> two columns. The first column contains a web server checkbox
> dynamically created and the second column simply contains text of
> whatever I put in. This is running fine. If I check the checkbox, how
> would I check if this checkbox is checked or not during postback? The
> dynamically
> created checkbox seems to have disappeared during postback.
>
> Thanks in advance.
>
>


May 2 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.