Wednesday, October 19, 2011

How to Read Key & Values From AppSettings and Assign in List

public class URLs
    {
        public string Name { get; set; }
        public string Url { get; set; }
    }

    void BindGrid()
        {
            List<URLs> ObjUrls = new List<URLs>();
            foreach (string key in ConfigurationSettings.AppSettings)
            {
                string value = ConfigurationManager.AppSettings[key];
                ObjUrls.Add(new URLs() { Name = key, Url = value });
            }
            if (ObjUrls.Count > 0)
            {
                GrdAppUrls.DataSource = ObjUrls;
                GrdAppUrls.DataBind();
            }
        }

No comments:

Post a Comment