请帮助我如何恢复它。我使用了ddlHassection.Items.Clear();但它不能正常工作。
using (var context = new SMAPPDBEntities())
{
var addDept = new SMDepartment
{
DepartmentCode = txtDeptCode.Text,
DepartmentName = txtDeptName.Text,
UnitID= Convert.ToInt32( ddlUnitName.SelectedValue),
Description = txtDeptDescription.Text,
DepartmentHead = Convert.ToInt32(ddlDeptHeadName.SelectedValue),
HasSection = Convert.ToBoolean(ddlHasSection.SelectedValue),
Tag= txtDeptTag.Text
};
try
{
context.SMDepartment.Add(addDept);
context.SaveChanges();
}
catch (Exception ex)
{
ex.ToString();
}
}
答案 0 :(得分:1)
protected void DropDownList1_SelectedIndexChanged1(object sender, EventArgs e)
{
DropDownList1.Items.Clear();
}
or
DDL1.ClearSelection();