[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Dynamic checkbox control in SharePoint 2007 web part

Posted on 2008-06-23
5
Medium Priority
?
1,689 Views
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;
                        strLenderName.Add(chkBool.ID.ToString());
                        i++;
                    }
                }
 
                if (child.Controls.Count > 0)
                {
                    IterateControls(child);
                }
            }
           
           
            for (int j = 0; j < strLenderName.Count; j++)
            {
                Page.Response.Write("strLenderName" + strLenderName[j].ToString());
            }
        }
 
 
        private void btnSubmit_Click(Object Sender, EventArgs e)
        {
            try
            {
                
                IterateControls(this);
                
            }
            catch (Exception eXSubmt)
            {
                Page.Response.Write("Error Message" + eXSubmt.Message);
            }
        }

Open in new window

0
Comment
Question by:lakshmidurga
[X]
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
5 Comments
 
LVL 3

Accepted Solution

by:
argodev earned 2000 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 asp.net 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.
http://aspnet.4guysfromrolla.com/articles/092904-1.aspx 
0
 
LVL 7

Author Comment

by:lakshmidurga
ID: 22004441
close this question.Thanks for Helping
0
 
LVL 3

Expert Comment

by:argodev
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.
0

Featured Post

Looking for a new Web Host?

Lunarpages' assortment of hosting products and solutions ensure a perfect fit for anyone looking to get their vision or products to market. Our award winning customer support and 30-day money back guarantee show the pride we take in being the industry's premier MSP.

Question has a verified solution.

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

Using Quotation Marks in PHP This question (http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/Q_28217211.html) seems to come up a lot for developers who are new to PHP.  And it got me thinking, "How can we explain the rule…
These days, all we hear about hacktivists took down so and so websites and retrieved thousands of user’s data. One of the techniques to get unauthorized access to database is by performing SQL injection. This article is quite lengthy which gives bas…
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…
Learn how to set-up custom confirmation messages to users who complete your Wufoo form. Include inputs from fields in your form, webpage redirects, and more with Wufoo’s confirmation options.

650 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