protected void DetailsView2_ItemInserted(object sender, DetailsViewInsertedEventArgs e)
    {
        GridViewMove.DataBind();
        DropDownList myDDNewUnit = DetailsView2.FindControl("DDNewUnit") as DropDownList;
        string connectionString = ConfigurationManager.ConnectionStrings["MyDB"].ConnectionString;
        SqlConnection myConnection = new SqlConnection(connectionString);
        myConnection.Open();
        String StrQ = "select unitid from unit where 单位名称='" + myDDNewUnit.SelectedValue.ToString() + "'";
        SqlCommand myCommand = new SqlCommand(StrQ, myConnection);
        SqlDataReader myReader = myCommand.ExecuteReader();
        myReader.Read();
        string NewUnit;
        NewUnit = myReader[0].ToString();
        myReader.Close();        DropDownList myDDNewDepartment = DetailsView2.FindControl("DDNewDepartment") as DropDownList;
        String StrQDepartmentId = "select departmentid from department where 部门名称='" + myDDNewDepartment.SelectedValue.ToString() + "' and  unitid=" + NewUnit;
        SqlCommand myCommand1 = new SqlCommand(StrQDepartmentId, myConnection);
        SqlDataReader myReader1 = myCommand1.ExecuteReader();
        myReader1.Read();
        string NewDepartment = myReader1[0].ToString();
        myReader1.Close();        TextBox myBabyId = DetailsView2.FindControl("TextBoxBabyId") as TextBox;
        if (myBabyId != null)
        {
            String StrBabyId = "UPDATE baby SET departmentid =" + NewDepartment + " where BabyId=" + e.Values["BabyId"];
            SqlCommand myCommand2 = myConnection.CreateCommand();
            myCommand2.CommandText = StrBabyId;
            myCommand2.ExecuteNonQuery();
            //SqlCommand sqlcmd = new SqlCommand(StrBabyId, myConnection);
            //sqlcmd.ExecuteNonQuery();        }
    }为什么一运行就提示"在没有任何数据时进行无效的读取尝试"?而且DropDownList里没有填充进我要的东西~