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/sitecolection/"))
                using (SPWeb web = site.OpenWeb())
                    SPList list = web.Lists["Departments"];
                    dropDep.DataSource = list.Items;
                    dropDep.DataValueField = "Title";
                    dropDep.DataTextField = "Title";

Add below line of code under dropDep.DataBind();

ListItem newItem = new ListItem("Not a dept", "0");
dropDep.Items.Insert(0, newItem);
  • Please help me for this question ... ----> link – Goshky Mar 16 '16 at 9:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.