Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / February 2008

Tip: Looking for answers? Try searching our database.

determining dynamic checkbox control's Checked value

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
J - 18 Feb 2008 03:47 GMT
I'm dynamically adding checkboxes in the Page_Load (regardless of PostBack).
When IsPostBack, the checkboxes display as I expected and their
checked/unchecked status is also as expected.  At this point, I want to find
particular checkboxes and determine whether they are check/unchecked, but
the code only returns that all the checkboxes are unchecked.

void SaveModel(Control parent)
{
   // spin through controls recursively
   foreach (Control c in parent.Controls)
   {
       if (c.ID != null && c.ID.IndexOf("cbxModel") >= 0)
       {
           //  ? ((CheckBox).c).Text displays the correct value at this
point, BUT.....

           //-->> this is not detecting the box checked although it's
clearly checked in the browser
           if (((CheckBox)c).Checked == true)
           {
                  //save to db here
            }
        }
        if (c.Controls.Count > 0)
        {
            SaveModel(c);
        }
    }
}

Thanks.
Masudur - 18 Feb 2008 08:11 GMT
> I'm dynamically adding checkboxes in the Page_Load (regardless of PostBack).
> When IsPostBack, the checkboxes display as I expected and their
[quoted text clipped - 28 lines]
>
> Thanks.

Hi...

After loading the dynamically created controls in post back ...
asp.net automatically assignes statechanges of the controls...

you have to make sure that you do check your changes after you loading
the dynamically loaded controls...

Md. Masudur Rahman
www.munna.shatkotha.com

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.