Pages

Monday, 10 February 2014

Insert and remove items from a dropdown list in c#

Remove Item:
    CurrentList = (DropDownList)CurrentRow.FindControl("ddlStatus");
                    using (WorkflowMgmt wf = new WorkflowMgmt())
                    {
                        wf.GetStatus("Vendor", "VEN", CurrentList, "Select Status", "0");
                        if (CurrentRow.Cells[28].Text.Trim() != "1003")
                        {
                            ListItem removeItem = CurrentList.Items.FindByText("Cancelled by Customer");
                            CurrentList.Items.Remove(removeItem);
                        }
                    }

Insert Item:
      ddlSourcingExecutor.Items.Insert(0, new ListItem("Select Executor", "0"));

No comments:

Post a Comment