我如何在asp下拉列表中应用引导从objectdatasource获取数据

本文关键字:objectdatasource 数据 获取 应用 asp 下拉列表 | 更新日期: 2023-09-27 18:06:00

如何在asp下拉列表中应用bootstrap从objectdatasource获取数据?

旧代码运行得很好。下面是旧代码

<asp:DropDownList ID="uxLocations" runat="server" 
                  DataSourceID="ObjectDataSource1" DataTextField="Name" DataValueField="ID" 
                  Height="24px" Width="200px" AutoPostBack="True" 
                  onselectedindexchanged="uxLocations_SelectedIndexChanged">
</asp:DropDownList>
<asp:ObjectDataSource ID="ObjectDataSource1" runat="server" 
                      SelectMethod="GetLocations" 
                      TypeName="Domain.LocationManager">
</asp:ObjectDataSource>

我尝试应用bootstrap,但列表没有正确显示,不像当你使用"ul和li"标签硬编码列表,正如http://www.w3schools.com/bootstrap/bootstrap_ref_comp_dropdowns.asp

所示

我是这样做的:[不好]

<div class="dropdown">
<button class="btn btn-default dropdown-toggle" type="button" id="menu1" 
 data-toggle="dropdown">Locations
<span class="caret"></span></button>
<asp:DropDownList ID="uxLocations" runat="server" AutoPostBack="True" 
 CssClass="dropdown-menu" DataSourceID="ObjectDataSource1" 
 DataTextField="Name" DataValueField="ID" Height="24px" Width="200px">
</asp:DropDownList>
<asp:ObjectDataSource ID="ObjectDataSource1" runat="server" 
    SelectMethod="GetLocations" 
    TypeName="Domain.LocationManager">
</asp:ObjectDataSource>
</div>

帮助。

我如何在asp下拉列表中应用引导从objectdatasource获取数据

Bootstrap的按钮下拉菜单不适合select元素。你必须自己滚动,或者使用bootstrap-select之类的选项。

使用bootstrap-select,您只需将下拉控件上的CssClass设置为"selectpicker",如下所示:

<asp:DropDownList ID="uxLocations" runat="server" AutoPostBack="True" 
 CssClass="selectpicker" DataSourceID="ObjectDataSource1" 
 DataTextField="Name" DataValueField="ID">
</asp:DropDownList>

我使用了CssClass="form-control"而不是CssClass="dropdown-menu",我尝试使用按钮下拉样式,但我需要快速完成。我想这已经满足我现在的需要了。也谢谢你的引导选择,我以后会探索的。

<div class="container">
<div class="row">
<div class="box">
<asp:DropDownList ID="uxLocations" runat="server" AutoPostBack="True" CssClass="form-control"
    DataSourceID="ObjectDataSource1" DataTextField="Name" DataValueField="ID" 
    Height="35px" Width="200px">
</asp:DropDownList>
<asp:ObjectDataSource ID="ObjectDataSource1" runat="server" 
    SelectMethod="GetLocations" 
    TypeName="CPRG255.InlandMarina.Domain.LocationManager">
</asp:ObjectDataSource>
</div>
</div>
</div>
相关文章:
  • 没有找到相关文章