Michael
Michael

Reputation: 13616

CheckBoxList unvisible

I can't see CheckBoxList control in browser.The visible property is set to true.

Here my ASP code:

<'asp:CheckBoxList ID="CheckBoxList1" runat="server" AutoPostBack="True">
    <'/asp:CheckBoxList>

here is code behind (I set a brake point near CheckBoxList1_PreRender,but in debug mode this event was ignored!!! ):

    protected void CheckBoxList1_PreRender(object sender, EventArgs e)
    {
        var ColorList = BL.FooBL.GetColorList();
        foreach (var item in ColorList)
        {
            CheckBoxList1.Items.Add(new ListItem(item.ColorName, item.ColorID.ToString()));
        }

     }

All other control I see in debbug mode on page except CheckBoxList1 control.

what may be the problem? Thank you in advance.

Upvotes: 0

Views: 104

Answers (1)

alhalama
alhalama

Reputation: 3228

The event doesn't fire because it isn't wired up. You can do this in code with the following:

protected override void OnInit(EventArgs e)
{
    base.OnInit(e);
    this.CheckBoxList1.PreRender+=new EventHandler(CheckBoxList1_PreRender);
}

Automatic event wire up only works for the page events.

Upvotes: 2

Related Questions