469,575 Members | 1,662 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,575 developers. It's quick & easy.

how to retrieve control value from dynamically created controls

i've got a script that creates a new tablerow + tablecell and appends that
to a non dynamically created table control. a new row is added for each
recordset returned from my sql statement. within each tablecell, i place a
dynamically created checkbox control. i now need to fetch back the value of
the checkbox as follows:

foreach (Control c in tblServices.Controls) {
}

this doesn't work, however. if i step through with the debugger, the only
controls listed under tblServices are the tablerows, not the checkbox.

how do i navigate down to the checkbox control so i can fetch the value?

tks.


Jun 21 '07 #1
2 2066
2 points:

1. You need to re-create dynamically created controls on every postback,
preferably in Page_Init event.

2. Controls property contains only immediate children. You need to drill
down row-cell-checkbox.

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
"Dica" <ge*****@hotmail.comwrote in message
news:qwwei.6056$xk5.1118@edtnps82...
i've got a script that creates a new tablerow + tablecell and appends that
to a non dynamically created table control. a new row is added for each
recordset returned from my sql statement. within each tablecell, i place a
dynamically created checkbox control. i now need to fetch back the value
of the checkbox as follows:

foreach (Control c in tblServices.Controls) {
}

this doesn't work, however. if i step through with the debugger, the only
controls listed under tblServices are the tablerows, not the checkbox.

how do i navigate down to the checkbox control so i can fetch the value?

tks.


Jun 21 '07 #2
"Eliyahu Goldin" <RE**************************@mMvVpPsS.orgwrote in
message news:uK**************@TK2MSFTNGP04.phx.gbl...
>2 points:

1. You need to re-create dynamically created controls on every postback,
preferably in Page_Init event.

2. Controls property contains only immediate children. You need to drill
down row-cell-checkbox.
thanks, eliyahu. i suspected it was something like that. i was expecting to
be able to get directly to the control but as you said, i had to drill down,
which i accomplished with a nested for loop.
--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
"Dica" <ge*****@hotmail.comwrote in message
news:qwwei.6056$xk5.1118@edtnps82...
>i've got a script that creates a new tablerow + tablecell and appends
that to a non dynamically created table control. a new row is added for
each recordset returned from my sql statement. within each tablecell, i
place a dynamically created checkbox control. i now need to fetch back
the value of the checkbox as follows:

foreach (Control c in tblServices.Controls) {
}

this doesn't work, however. if i step through with the debugger, the only
controls listed under tblServices are the tablerows, not the checkbox.

how do i navigate down to the checkbox control so i can fetch the value?

tks.



Jun 21 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by John Crowley | last post: by
7 posts views Thread by Sky | last post: by
3 posts views Thread by Eric | last post: by
1 post views Thread by powerranger | last post: by
9 posts views Thread by Chris | last post: by
4 posts views Thread by guiromero | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.