Asp.net 如何在页面加载事件上绑定多个下拉列表

Asp.net 如何在页面加载事件上绑定多个下拉列表,asp.net,Asp.net,在下面的代码中,我已经绑定了一个dropdownlist。如何绑定第二个dropdownlist 是,我在页面加载事件中绑定了多个dropdownlist 在其他情况下,我被利用了尝试,抓住 受保护的无效页面加载(对象发送方、事件参数e) { 如果(第IsPostBack页) { } else { try { da = new SqlDataAdapter("sele

在下面的代码中,我已经绑定了一个dropdownlist。如何绑定第二个dropdownlist


是,我在页面加载事件中绑定了多个dropdownlist 在其他情况下,我被利用了尝试,抓住

受保护的无效页面加载(对象发送方、事件参数e) { 如果(第IsPostBack页) {

        }

        else
        {
            try
            {
                da = new SqlDataAdapter("select distinct (EmpDepartment) from DepartmentMaster", con);
                da.Fill(ds, "deprt");
                ddldepartment.DataSource = ds.Tables["deprt"];
                ddldepartment.DataTextField = "EmpDepartment";
                ddldepartment.DataValueField = "EmpDepartment";
                ddldepartment.DataBind();
            }
            catch (Exception ex)
            {
                Response.Write(ex.Message);
            }
        }
            try
            {
                da = new SqlDataAdapter("select distinct (EmpDesignation) from DepartmentMaster", con);
                da.Fill(ds, "desig");
                DropDownList2. DataSource = ds.Tables["desig"];
                DropDownList2.DataTextField = "EmpDesignation";
                DropDownList2.DataValueField = "EmpDesignation";
                DropDownList2.DataBind();
            }
            catch (Exception ex)
            {
                Response.Write(ex.Message);
            }

        } 
        }

        else
        {
            try
            {
                da = new SqlDataAdapter("select distinct (EmpDepartment) from DepartmentMaster", con);
                da.Fill(ds, "deprt");
                ddldepartment.DataSource = ds.Tables["deprt"];
                ddldepartment.DataTextField = "EmpDepartment";
                ddldepartment.DataValueField = "EmpDepartment";
                ddldepartment.DataBind();
            }
            catch (Exception ex)
            {
                Response.Write(ex.Message);
            }
        }
            try
            {
                da = new SqlDataAdapter("select distinct (EmpDesignation) from DepartmentMaster", con);
                da.Fill(ds, "desig");
                DropDownList2. DataSource = ds.Tables["desig"];
                DropDownList2.DataTextField = "EmpDesignation";
                DropDownList2.DataValueField = "EmpDesignation";
                DropDownList2.DataBind();
            }
            catch (Exception ex)
            {
                Response.Write(ex.Message);
            }

        }