Dynamic checkbox control in SharePoint 2007 web part

Posted on 2008-06-23
Last Modified: 2010-05-18
I have created dynamic check boxes in SharePoint 2007 web part but I am not able to read the values of checkboxes which are checked. Please
private void IterateControls(Control Parent)
          foreach (Control child in Parent.Controls)
                if (child.GetType().ToString().Equals("System.Web.UI.WebControls.CheckBox"))
                    CheckBox chkBool = (CheckBox)child;
                    if (chkBool.Checked == true)
                        int i = 0;
                if (child.Controls.Count > 0)
            for (int j = 0; j < strLenderName.Count; j++)
                Page.Response.Write("strLenderName" + strLenderName[j].ToString());
        private void btnSubmit_Click(Object Sender, EventArgs e)
            catch (Exception eXSubmt)
                Page.Response.Write("Error Message" + eXSubmt.Message);

Open in new window

Question by:lakshmidurga
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2

Accepted Solution

argodev earned 500 total points
ID: 21851934
You indicated that you created the controls dynamically... when? during CreateChildControls or ?

Are you re-creating them on Page Init? Due to the flow of the page lifecycle, you have to re-create any dynamically created controls in Page_Init so that they exist prior to view-state being applied. If not, they are not there when the system applies viewstate and therefore the values are lost.

The following is an old, but helpful article on the topic. 

Author Comment

ID: 22004441
close this question.Thanks for Helping

Expert Comment

ID: 22015498
The answer provided would appear to have given the asker the solution needed. No counter question was asked nor was any clarification requested. In my opinion, points should be awarded for a correct answer rather than being refunded to the asker.

Featured Post

Why Off-Site Backups Are The Only Way To Go

You are probably backing up your data—but how and where? Ransomware is on the rise and there are variants that specifically target backups. Read on to discover why off-site is the way to go.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A Change in PHP Behavior with Session Write Short Circuit ( (Winter 2014)** With the release of PHP 5.6 the session handler changed in a way that many think should be considered a bug.  See the note …
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This video teaches viewers how to create their own website using cPanel and Wordpress. Tutorial walks users through how to set up their own domain name from tools like Domain Registrar, Hosting Account, and Wordpress. More specifically, the order in…
Use Wufoo, an online form creation tool, to make powerful forms. Learn how to selectively show certain fields based on user input using rules to gather relevant information and data from your forms. The rules feature provides you with an opportunity…

724 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question