如何创建可搜索的有界ASP下拉列表 [英] How to create searchable bounded ASP dropdownlist

查看:73
本文介绍了如何创建可搜索的有界ASP下拉列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的ASP WebForm中有一个有界的DropDownList。

它的界限是这样的:

i尝试使用JQuery(select2.js,dropdownsearchable.js)但没有任何工作!

有什么想法吗?



我的尝试:



I have a bounded DropDownList in my ASP WebForm.
it's bounded like this:
i tried to using JQuery (select2.js, dropdownsearchable.js) but nothing working!
any idea please?

What I have tried:

<pre><div class="form-group">
                
                <asp:DropDownList  ID="myDDL" runat="server" CssClass="form-control" AutoPostBack="true" DataSourceID="MyDS" DataTextField="EName" DataValueField="AID"></asp:DropDownList>
                <asp:SqlDataSource ID="MyDS" runat="server" ConnectionString="<%$ ConnectionStrings:Conn %>" SelectCommand="NamesListSP" SelectCommandType="StoredProcedure"></asp:SqlDataSource>
            </div>

推荐答案

ConnectionStrings:Conn% > SelectCommand = NamesListSP SelectCommandType = StoredProcedure > < / asp:SqlDataSource >
< / div >
ConnectionStrings:Conn %>" SelectCommand="NamesListSP" SelectCommandType="StoredProcedure"></asp:SqlDataSource> </div>


你不应该将服务器端实现与客户端实现混合在一起。标准的ASP.NET DropDownList控件是一个服务器控件,不支持开箱即用的搜索功能。以下是您可以做的事情:



如果您想实施服务器端方法,那么您可以尝试: AJAX Control Toolkit ComboBox [ ^ ]



如果要实现客户端方法,请使用jQuery Autocomlete: ASP.NET中的自动完成DropDownList替代方案 [ ^ ]。你也可以像你提到的那样使用jQuery Select2。



网上有很多例子可以说明如何实现它。只需在google上快速搜索ASP.NET中的DrodownList自动完成以获取更多示例。
You should not mix server-side implementation with client-side implementations. The standard ASP.NET DropDownList control is a server control and doesn't support search functionality out of the box. Here's what you can do:

If you want to implement server-side approach then you can try out: AJAX Control Toolkit ComboBox[^]

If you want to implement client-side approach, then use jQuery Autocomlete: AutoComplete DropDownList Alternatives In ASP.NET[^]. You can also use the jQuery Select2 as you mentioned.

There are plenty of examples on the web that demonstrate how to implement it. Just doa quick search at google about "DrodownList Autocomplete in ASP.NET" to get more examples.


这篇关于如何创建可搜索的有界ASP下拉列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆