下拉列表项选择 [英] DropdownList item select

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

问题描述

我的下拉列表是

My dropdownlist is

<asp:DropDownList ID="ddl1Board" runat="server" ValidationGroup="StdAdm">
                                                           <asp:ListItem Selected="True">CBSE</asp:ListItem>
                                                           <asp:ListItem>ICSE</asp:ListItem>
                                                   <asp:ListItem>BSEB</asp:ListItem>
                                                   </asp:DropDownList>



我的下拉列表值保存在数据库中.但是我检索数据库值,然后我不明白如何选择所选的dropdownlist值.
例如:-
我将bseb保存在数据库中并在数据库中检索bseb,然后我要用户选择bseb.



My dropdownlist value save in database. but i retrieve the database value then i not understand how to select the dropdownlist value selected.
for example:-
I save the bseb in database and retrieve the bseb in database then i want to user see to bseb is selected.

推荐答案

如果要保存项目文本,则可以将选定的项目检索为
DropDownList1.SelectedValue= ValuefromDatabase;

如果您使用的是索引.
DropDownList1.SelectedIndex=2(In this case);
If you are saving the Item text then you can retrieve selected item as
DropDownList1.SelectedValue= ValuefromDatabase;

If you are using Index.
DropDownList1.SelectedIndex=2(In this case);


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

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