如何从web.config文件中获取值 [英] how to get the values from web.config file
本文介绍了如何从web.config文件中获取值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这里我正在从web.config文件中获取值
它正在存储是/否",但我想将是/否"而不是是/否"存储到数据库中.
你能告诉我怎么做吗?
web.config
<add key="abc" value="Yes No" />
home.aspx
Here i am fetching the values from the web.config file
It is storing Yes/No but i want to store Y/N instead of Yes/No into the Database.
would you please tell me how to do that?
web.config
<add key="abc" value="Yes No" />
home.aspx
<asp:RadioButtonList ID="rblCDDH" runat="server" Font-Bold="True" ForeColor="Black">
home.aspx.cs
home.aspx.cs
rblCDDH.DataSource = ConfigurationManager.AppSettings["abc"].Split(' ');
rblCDDH.DataBind();
推荐答案
< b>< code>发送完整代码</code></b>
在这里,我正在从web.config文件中获取值.
它正在存储是/否",但我想将是/否"而不是是/否"存储到数据库中.
你能告诉我怎么做吗?
web.config
home.aspx
< asp:RadioButtonList ID ="rblCDDH" runat ="server" Font-Bold ="True" ForeColor ="Black">
home.aspx.cs
rblCDDH.DataSource = ConfigurationManager.AppSettings ["abc"].Split('''');
rblCDDH.DataBind();
<b><code>Send whole code</code></b>
Here i am fetching the values from the web.config file
It is storing Yes/No but i want to store Y/N instead of Yes/No into the Database.
would you please tell me how to do that?
web.config
home.aspx
<asp:RadioButtonList ID="rblCDDH" runat="server" Font-Bold="True" ForeColor="Black">
home.aspx.cs
rblCDDH.DataSource = ConfigurationManager.AppSettings["abc"].Split('' '');
rblCDDH.DataBind(); .
您要分配给rblCDDH
的数据源是String数组,其值分别为Yes
和No
.
如果希望该值是Y/N,则将其保存在web.config
中,或将字符串用''/''分隔,然后使用substring
方法仅获取每个字符串的第一个字符;否则,使用substring
方法.将它们与斜线连接在一起.
我将把编写代码的工作留给您.
The datasource that you are assigning to therblCDDH
is String array which has valuesYes
andNo
.
If you want the value to be Y/N, save it that way in theweb.config
or split the string by ''/'' then get only the first characters of each of the string usingsubstring
method; concatenate them along with a slash.
I will leave the writing code for it up to you.
这篇关于如何从web.config文件中获取值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文