Hello there,
I am using ASP.NET with C# and facing below problem. I am not able to get values of selected checkboxes which are generated dynamically.
Pls have a look at the image attached with the message…
Waiting for your reply…
Thanks,
Paresh
Hello there,
I am using ASP.NET with C# and facing below problem. I am not able to get values of selected checkboxes which are generated dynamically.
Pls have a look at the image attached with the message…
Waiting for your reply…
Thanks,
Paresh
Try this.
for each cControl in pn1.Controls
If TypeOf cControl Is CheckBox Then
dim cbox as CheckBox = Ctype(cControl, CheckBox)
if cbox.Checked = True Then
Response.Write(c.Text)
end if
End If
next cControl
Richard M.
no C# and they are dynamic written thus something like this:
foreach (ListItem li in CHECKBOXLIST_NAME_HERE.Items)
{
if (li.selected)
{
// do whatever here
}
}
maybe even surrend the individual loops with a control look like in the previous post
ahh nevermind you cannot reference a control written in a label as you are, the control will NEVER be registered with the page.
To do so you MUST create in code:
HTMLTextBox MyBox = new HTMLTextBox();
and then assign properties then write it to the page. Then you will be abble to reference it from the code behind.
I think and easier way would be to change the way you create your fields.