Click here to Skip to main content
15,042,403 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
I have an Entry form and search page. (both aspx files) By default when someone views the entry page it is blank and they enter the data related to the Textboxes, dropdownlists, and checkboxes.

Now the search page lets the user search previous entries and edit them as well. My go is to enable the user to search for previous entries, selects one, and then take them to the prefilled entrypage (via hyperlink) to edit the data.

Everything is working fine except for I'm unsure how to load the checkboxes from the database I'm pulling from. The code to Fill the form is below:

private void FillForm(int accountEntryID)
           var loadAccountEntryByID = new AccountTrackerEntrySVC().LoadAccountEntryByID(accountEntryID);

            //Check if object is valid
           if (loadAccountEntryByID.AccountEntryID > 0)
               uxMainFormPnl.Visible = true;

               uxAccountNumTxt.Text = loadAccountEntryByID.AccountEntryID.ToString();
               uxPhysicalLocationTxt.Text = loadAccountEntryByID.PhysicalLocationDesc;
               uxPasswordChangeFrequencyDescTxt.Text = loadAccountEntryByID.PasswordChangeFrequency;
               uxDataBeingTransferredDescTxt.Text = loadAccountEntryByID.DataBeingTransferredDesc;

               // DDL's: Data Choice, Type of Connection
               uxDataChoiceDdl.DataValueField = DataConverter.ObjectToString(loadAccountEntryByID.DataChoiceNum);
               uxTypeOfconnectionDescTxt.DataValueField = DataConverter.ObjectToString(loadAccountEntryByID.ConnectionTypeDesc);

               // Check boxes: Password Protected
               bool selected = false;
               if (PasswordProtectedCB.Checked == false)
               {   selected = false;

                   selected = true;
                   PasswordProtectedCB = DataConverter.ObjectToBool(loadAccountEntryByID.PasswordProtected);//Error in title returned here.

Long story short if I can fix: the coversion error listed in the title, I think I should be fine. Any ideas on how to go about this?

The notion of "convert" is nonsense here. The control cannot be Boolean; it can have Boolean value describing the state:[^].

Afzaal Ahmad Zeeshan 24-Jul-15 14:01pm
Sergey Alexandrovich Kryukov 24-Jul-15 15:46pm
Thank you, Afzaal.
you can set CheckBox.Checked property from the value you stored. for example
PasswordProtectedCB.Checked = DataConverter.ObjectToBool(loadAccountEntryByID.PasswordProtected)
Afzaal Ahmad Zeeshan 24-Jul-15 14:01pm

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900