Uncategorized

Populate DropDownList from List in SharePoint 2010 Visual Web Part

SPWeb web = SPControl.GetContextWeb(HttpContext.Current);
                SPList supervisorList = web.Lists["SupervisorList"];

                if(supervisorList !=null)
                {
                    ddlSupervisor.Items.Clear();
                    foreach (SPListItem items in supervisorList.Items)
                    {
                        string supervisorName = items["SupervisorName"].ToString();
                        ddlSupervisor.Items.Add(supervisorName);
                    }
                    ddlSupervisor.DataBind();
                }

Standard

Leave a Reply

Your email address will not be published. Required fields are marked *