weixin_33724659 2011-01-07 22:55 采纳率: 0%
浏览 24

组合框项目不显示

This question has been asked here before, but the author wasn't very clear and got no answers (1st ref). Why aren't my combobox items displaying correctly? It is almost like they are there, but not connected to the combobox (notice my label, it shows up halfway down the page instead of right underneath the combobox when I run it). I get no errors on the page, which is good (different than when I tried doing this in VS2005), and the combobox displays fine, but when I click it, nothing is there.

 <html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>
        <asp:ComboBox ID="ComboBox1" runat="server" AutoPostBack="true" 
            DropDownStyle="DropDownList">
          <asp:ListItem>thisis</asp:ListItem>
          <asp:ListItem>mynetwork</asp:ListItem>
          <asp:ListItem>getoffmyjunk</asp:ListItem>
          <asp:ListItem>itsmine</asp:ListItem>
          <asp:ListItem>illkillyou</asp:ListItem>
          <asp:ListItem>forrealz</asp:ListItem>
          <asp:ListItem>what</asp:ListItem>
          <asp:ListItem>didyousaysomething</asp:ListItem>
          <asp:ListItem>didn'tthinkso</asp:ListItem>
          <asp:ListItem>meh</asp:ListItem>
        </asp:ComboBox>
        <br />
        <asp:Label ID="lbl" runat="server">default text</asp:Label>
    </div>
    </form>
</body>
</html>

https://stackoverflow.com/questions/4322922/combo-box-items-does-not-display-below-of-combo-box-why

I'm having the same problem as this guy: http://p2p.wrox.com/book-asp-net-ajax-programmers-reference-asp-net-2-0-asp-net-3-5-isbn-978-0-470-10998-4/80267-ajax-combobox-not-displaying-item-list-correctly.html

  • 写回答

2条回答 默认 最新

  • weixin_33743661 2011-01-07 23:25
    关注

    Your syntax looks to be incorrect for the ComboBox control. You want to use the Text and Value parameters in order to get the options to display. You'll want it to look like this:

    <asp:ComboBox ID="ComboBox1" runat="server" AutoPostBack="true" DropDownStyle="DropDownList">
       <asp:ListItem Text="thisis" Value="thisis"></asp:ListItem>
       <asp:ListItem Text="mynetwork" Value="mynetwork"></asp:ListItem>
       <asp:ListItem Text="getoffmyjunk" Value="getoffmyjunk"></asp:ListItem>
    </asp:ComboBox>
    

    Note: You may also be running into issues with your control tag declaration. For example, when I import the AJAX Control Toolkit into my applications, and add the proper references, I wind up using the tag "cc1" for all of the AJAX Control Toolkit controls. You may need to double check these references as well.

    评论

报告相同问题?

悬赏问题

  • ¥15 求解 yolo算法问题
  • ¥15 虚拟机打包apk出现错误
  • ¥30 最小化遗憾贪心算法上界
  • ¥15 用visual studi code完成html页面
  • ¥15 聚类分析或者python进行数据分析
  • ¥15 三菱伺服电机按启动按钮有使能但不动作
  • ¥15 js,页面2返回页面1时定位进入的设备
  • ¥50 导入文件到网吧的电脑并且在重启之后不会被恢复
  • ¥15 (希望可以解决问题)ma和mb文件无法正常打开,打开后是空白,但是有正常内存占用,但可以在打开Maya应用程序后打开场景ma和mb格式。
  • ¥20 ML307A在使用AT命令连接EMQX平台的MQTT时被拒绝