Click here to Skip to main content
15,886,518 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi..,

How to set Check Box or Radio button value based on webconfig on asp.net?

Like 2-3 checkbox is there on one page. Based on web configuration if 1st checkbox value is default then 1st Checkbox should checked on the page.

plese help....


Thanks..
Posted
Comments
Jameel VM 14-Aug-14 5:38am    
did you put the entries in web.config?

1 solution

In Web.config:
XML
<appSettings>
   <add key="defaultCheckBox" value="CPP"/>

 </appSettings>



In aspx:

XML
<asp:CheckBoxList ID="CheckBoxList1" runat="server">
        <asp:ListItem>Java</asp:ListItem>
        <asp:ListItem>c#</asp:ListItem>
        <asp:ListItem>CPP</asp:ListItem>
        <asp:ListItem>SQL</asp:ListItem>
    </asp:CheckBoxList>



In aspx.cs file:
C#
string defaulCheckBox = System.Configuration.ConfigurationManager.AppSettings["defaultCheckBox"];
            CheckBoxList1.SelectedValue = defaulCheckBox;
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900