Skip to main content
2 of 3
edited title
Goshky
  • 2.1k
  • 4
  • 25
  • 49

SharePoint - How to set default value in DropDownMenu which takes data in SPList?

I Have list "Department" and takes the data from it. I want the first value in DropDownMenu to be "Not a dept"...


enter image description here


protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            using (SPSite site = new SPSite("http://sf-spsdev04/sites/gkk92/"))
            {
                using (SPWeb web = site.OpenWeb())
                {
                    SPList list = web.Lists["Departments"];
                    dropDep.DataSource = list.Items;
                    dropDep.DataValueField = "Title";
                    dropDep.DataTextField = "Title";
                    dropDep.DataBind();
                }
            }
        }
    }
Goshky
  • 2.1k
  • 4
  • 25
  • 49