This is a migrated thread and some comments may be shown as answers.

Checkboxlist inside UserControl Edit Form

1 Answer 69 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Vinh
Top achievements
Rank 1
Vinh asked on 07 Oct 2010, 08:56 PM
I would like to see if you have any examples on how to check the box for the checkboxlist and/or radiobuttonlist.
The UserControl has several checkboxlists and radiobuttonlists and referenced by ID.
Example: 
I have tblOrder which has OrderFrequencyID, OrderReportTypeID.  There are two checkboxlists on that usercontrol, 1 for Frequency and 1 for ReportType.  When I click on Edit, I want to have the checkboxlists checked the box(es). 

Problem:
As I debug, I can see the checkboxes are checked but on the IE, the boxes arent checked.

Thanks

Vinh

1 Answer, 1 is accepted

Sort by
0
Vinh
Top achievements
Rank 1
answered on 07 Oct 2010, 10:28 PM
Problem solved by using the override void Render

protected override void Render(System.Web.UI.HtmlTextWriter writer)
        {
            ...
            DataTable dt = ...;
            foreach (DataRow row in dt.Rows)
            {
                ListItem currentCheckBox = CheckBoxList5.Items.FindByValue(row["FrequencyID"].ToString());
                if (currentCheckBox != null)
                {
                    currentCheckBox.Selected = true;
                }
            }
  
            // Call the base class's Render method.
            base.Render(writer);
        }

Thanks

Vinh Vu
Tags
Grid
Asked by
Vinh
Top achievements
Rank 1
Answers by
Vinh
Top achievements
Rank 1
Share this question
or