复选框列表不可见

发布于 2024-12-26 16:18:31 字数 670 浏览 4 评论 0原文

我在浏览器中看不到 CheckBoxList 控件。visible 属性设置为 true。

这是我的 ASP 代码:

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

这里是代码隐藏(我在 CheckBoxList1_PreRender 附近设置了一个制动点,但在调试模式下此事件被忽略!!!):

    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()));
        }

     }

我在页面上的调试模式下看到的所有其他控件,除了 CheckBoxList1 控件。

可能是什么问题? 先感谢您。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

这样的小城市 2025-01-02 16:18:31

该事件不会触发,因为它未连接。您可以使用以下代码在代码中执行此操作:

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

自动事件连接仅适用于页面事件。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文