在下拉列表中设置值 [英] set value in dropdownlist

查看:105
本文介绍了在下拉列表中设置值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我正在asp.net网站上工作.在页面加载中,我使用所有国家/地区名称填充国家/地区下拉列表.之后,我有一个搜索面板.
在这种情况下,当我选择一个用户名时.然后我要在下拉列表中选择用户的国家/地区名称.
所以给我一个主意,我该怎么做?
请给我任何链接或任何解决方案.

Hello Every One,

I am working in asp.net website. On Page load i am filling country dropdownlist with all countries name. after that i have a search panel.
in this when i select a username. then i want to select user''s country name in dropdownlist.
so give me any idea how can i do this?
please give me any link or any solution.

推荐答案

当我选择用户名时.然后我要在下拉列表中选择用户的国家/地区名称.
最好并且可以肯定的是,您需要在用户注册时捕获其国家/地区.
因此,在登录时,您将拥有较早捕获的用户的详细信息.按照先前捕获的设置国家/地区的下拉值.

步骤如下:
1.注册用户名时,请捕获国家/地区以及其他详细信息(如果有的话)
2.登录时,找到与用户名关联的国家/地区
3.使用找到的国家/地区作为用户名,将其设置在国家/地区下拉列表中

尝试!
when i select a username. then i want to select user''s country name in dropdownlist.
Best and to be sure, it you need to capture the country of user when they register.
Thus, on login, you have details of the user captured earlier. Set the dropdown value of country as per captured earlier.

So steps:
1. While registering a username, capture country along with other details if any
2. At the time of login, find the country associated with the username
3. Use the country found for the username to set it in country dropdownlist

Try!


我找到了解决方案.代码如下:

i found the solution of this. code is following:

ddlCountry.SelectedIndex = ddlCountry.Items.IndexOf(ddlCountry.Items.FindByValue(countryname));


国家名是我要在下拉列表中设置的值.


countryname is value which i want to set in dropdownlist.


这篇关于在下拉列表中设置值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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