I have an appSetting block that looks like this:
<appSettings> <key="site1" value="http://www.thissite.com,site name" /> <key="site2" value="http://www.thissite.com,site name" /> </appSettings>
I want to populate a dropdown with values ββand text:
value = "http://www.thissite.com" text = "site name"
I can get them in separate arrays using this:
string[] mykey = ConfigurationManager.AppSettings["site1"].Split(','); string[] mykey = ConfigurationManager.AppSettings["site2"].Split(',');
however, I want to combine them into a single array, and then scroll and populate the code drop-down list. I can fill it this way by going through separate arrays, but it seems like there should be a better way with less code.
Can anyone tell me how?
credit to you all, except for the gratitude to acermate433s below.
NameValueCollection appSettings = ConfigurationManager.AppSettings; for (int i = 0; i < appSettings.Count; i++) { Response.Write(appSettings.GetKey(i).ToString() + "-" + appSettings[i].ToString()); }
Obviously, I will do a little more than just show it.
Adam
source share