从web.config填充下拉列表值 [英] fill dropdown list value from web.config

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

问题描述

如果我有几个与所有相关的下拉列表,谁知道要从web.config填写下拉列表值?例如:如果我选择ddlA,则ddlB会给我基于ddlA的值,与ddlC和ddlD相同.

目前,我只知道如何在下面的下拉列表中填充所有内容,但是我准备需要的是:
当用户选择Gre-->我只会在ddl2中显示A,B,C;
当用户选择Phi->时,我只需要在ddl2中显示D,E,F.
希望有人可以给我更多详细的vb步骤


Anyone know to fill dropdown list value from web.config if i have few dropdownlist which all is related? eg: if i select ddlA, then ddlB will give me the value base on ddlA, same as ddlC and ddlD..?

Currently i only know how to fill it all in the dropdownlist as below, but what I ready need is;
when user select Gre -> I will only show A,B,C in the ddl2;
when user select Phi-> I need to show D,E,F in ddl2 only.
Hope someone can give me more detail step in vb


<add key="Value1" value="Gre, Phi" />
    <add key="Value2" value="A,B C,D E,F" />
    <add key="Value3" value="..." />

推荐答案

我不确定为什么要使用网络.config,但是您可以将XML值存储为字符串,然后解析该XML以获取下拉列表值.如果它不是分层式的(如您的帖子所暗示的),则可以使用CSV,您不能只存储b/c值,而存在一个不确定的数字,它将变得丑陋.就个人而言,我将它们存储在app_data中的文件中并读取,如果您必须从Web服务器上的文件而不是数据库中配置内容(我的首选)
I am not sure why you want to use the web.config but you CAN store an XML value as a string, and pars that XML to get your drop down list values. If it''s not heirarchical ( as your post seems to imply ) then you could use a CSV, you can''t just store values b/c there''s an indeterminate number and it will get ugly. Personally, I''d store them in a file in app_data and read that, instead, if you must configure the content from a file on your web server and not from a database ( my first choice )


您可以使用一组级联的下拉菜单.
这些链接位于C#中,但是您可以尝试将此代码转换为VB.Net-
http://csharpdotnetfreak.blogspot.in/2009/03/populate-dropdown- based-selection-other.html [ ^ ]
You can use a set of cascading dropdowns.
These links are in C#, but you can try and convert this code to VB.Net -
http://csharpdotnetfreak.blogspot.in/2009/03/populate-dropdown-based-selection-other.html[^]


尝试一下.
try this one.
Dim strPwd As String
Dim i As Integer

strPwd = ConfigurationManager.AppSettings("Value1")

Dim arrPwd = Split(strPwd, ", ")

For i = 0 To UBound(arrPwd)
    ddlValue1.items.add(arrPwd(i))
Next


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

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