下拉列表框根据数据库值选择值 [英] dropdown list box select value according to database value

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

问题描述

我有这样的代码

I have code like this

Dim office1 = read1("Office_Cd").ToString()
            ddl_editOffice.SelectedValue = read1("Office_Cd").ToString()



i已填充dropdownlistbox

和数据库office_Cd给出

i get office_Cd

现在我想在这个ddl已经选择办公室代码

假设在ddl我填写

office_Cd office_NM

0选择

1 a

2 b

3 c

我得到2现在我想要我的ddl选择2

plz尽快解决这个问题谢谢

其代码编辑用户在哪里办公室已选择符合数据库价值

谢谢


i have dropdownlistbox filled
and in database office_Cd given
i get office_Cd
now i want that in this ddl already select office code
suppose in ddl i fill
office_Cd office_NM
0 select
1 a
2 b
3 c
and i get 2 now i want that my ddl select 2
plz solve this problem as soon as possible thanks
its code to edit user where office already selected accoring to database value
thanks

推荐答案

请尝试以下方式你为Dootind下拉列表进行编辑



Try as below after you databind the Dropdownlist for editing

ddl_editOffice.Items.FindByValue(read1("Office_Cd").ToString()).Selected = true





甚至





Or even

ddl_editOffice.SelectedIndex = ddl_editOffice.Items.IndexOf(ddl_editOffice.Items.FindByValue(read1("Office_Cd").ToString()))


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

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