数据按顺序设置的下拉列表的C#代码 [英] c# code for dropdown list whose data are set in order

查看:153
本文介绍了数据按顺序设置的下拉列表的C#代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的项目中有一个带有城市名称的下拉列表,我希望当我写第一个城市的alphabate时,所有以该alphabate开头的城市名称都显示在系列下拉列表中,所以我该怎么做? > 请给我这个

i have a dropdownlist in my project with city name i want that when i write first alphabate of city then all the cities whose name is start with that alphabate are show in series i dropdown list so what i do??
please give me c# code for this

推荐答案

嗨的c#代码
使用城市名称顺序从数据库中选择城市名称
Hi
Select the city name from database using order by cityname


请为此给我c#代码
它在这里不能这样工作.

这是询问者的期望:
1. 先尝试您要做什么!您可能会发现它并不难.
2.制定看起来像问题/无法解决的问题.

试试看,告诉他们是否遇到问题.
成员将很乐意为您提供帮助.


现在,由于您还没有提到Winforms或Web,因此不会共享任何链接.逻辑如下:
Winforms:有一个自动完成属性为true的组合框,这样键入开始字符即可显示所有可能的名称.
Web:具有客户端功能将是有意义的,并提供了更好的可用性.因此,放置一个文本框,为其定义一个onkeypress,然后使用AJAX,从服务器获取与其相关的数据,绑定并在文本框下方的div中显示(以下拉列表形式显示).您也可以使用ASP.NET AJAX扩展器.另一种选择是使用jQuery自动完成插件.

现在,继续尝试,然后尝试发布特定问题(如果您遇到问题).
please give me c# code for this
It does not work like this here.

Here is what is expected of enquirers:
1. TRY first what you want to do! You may find that it''s not that hard.
2. Formulate what was done by you that looks like an issue/not working.

Try them and tell if you face issues.
Members will be more than happy to help like this.


For now, since you have not mentioned winforms or web, will not share any link. Here is the logic:
Winforms: Have a combobox with autocomplete property true such that typing start characters show all the possible names.
Web: Having the functionality client side would make sense and give better useability. So, place a textbox, define a onkeypress for it and then using AJAX, get the data related to it from server, bind and show in a div below textbox (to show it as a dropdown). You can use ASP.NET AJAX extender too for it. Other option is to have jQuery autocomplete plugin.

Now, go ahead, try out and then post specific issue if you face.


这篇关于数据按顺序设置的下拉列表的C#代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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