ddl的aotopostback 这段代码有误?
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { DDLFamilyRelationship1st.Items.Insert(0, new ListItem("-请选择-", "0")); DDLFamilyRelationship2nd.Items.Insert(0, new ListItem("-请选择-", "0")); DDLFamilyRelationship3th.Items.Insert(0, new ListItem("-请选择-", "0")); DDLFamilyRelationship4th.Items.Insert(0, new ListItem("-请选择-", "0")); if (DDLSex.Text == "男") { DDLFamilyRelationship1st.Items.Insert(1, new ListItem("父子", "0")); DDLFamilyRelationship1st.Items.Insert(2, new ListItem("母子", "0")); DDLFamilyRelationship1st.Items.Insert(3, new ListItem("夫妻", "0")); DDLFamilyRelationship1st.Items.Insert(4, new ListItem("兄妹", "0")); DDLFamilyRelationship1st.Items.Insert(5, new ListItem("姐弟", "0")); DDLFamilyRelationship2nd.Items.Insert(1, new ListItem("父子", "0")); DDLFamilyRelationship2nd.Items.Insert(2, new ListItem("母子", "0")); DDLFamilyRelationship2nd.Items.Insert(3, new ListItem("夫妻", "0")); DDLFamilyRelationship2nd.Items.Insert(4, new ListItem("兄妹", "0")); DDLFamilyRelationship2nd.Items.Insert(5, new ListItem("姐弟", "0")); DDLFamilyRelationship3th.Items.Insert(1, new ListItem("父子", "0")); DDLFamilyRelationship3th.Items.Insert(2, new ListItem("母子", "0")); DDLFamilyRelationship3th.Items.Insert(3, new ListItem("夫妻", "0")); DDLFamilyRelationship3th.Items.Insert(4, new ListItem("兄妹", "0")); DDLFamilyRelationship3th.Items.Insert(5, new ListItem("姐弟", "0")); DDLFamilyRelationship4th.Items.Insert(1, new ListItem("父子", "0")); DDLFamilyRelationship4th.Items.Insert(2, new ListItem("母子", "0")); DDLFamilyRelationship4th.Items.Insert(3, new ListItem("夫妻", "0")); DDLFamilyRelationship4th.Items.Insert(4, new ListItem("兄妹", "0")); DDLFamilyRelationship4th.Items.Insert(5, new ListItem("姐弟", "0")); } if (DDLSex.Text == "女") { DDLFamilyRelationship1st.Items.Insert(1, new ListItem("父女", "0")); DDLFamilyRelationship1st.Items.Insert(2, new ListItem("母女", "0")); DDLFamilyRelationship1st.Items.Insert(3, new ListItem("夫妻", "0")); DDLFamilyRelationship1st.Items.Insert(4, new ListItem("兄妹", "0")); DDLFamilyRelationship1st.Items.Insert(5, new ListItem("姐弟", "0")); DDLFamilyRelationship2nd.Items.Insert(1, new ListItem("父女", "0")); DDLFamilyRelationship2nd.Items.Insert(2, new ListItem("母女", "0")); DDLFamilyRelationship2nd.Items.Insert(3, new ListItem("夫妻", "0")); DDLFamilyRelationship2nd.Items.Insert(4, new ListItem("兄妹", "0")); DDLFamilyRelationship2nd.Items.Insert(5, new ListItem("姐弟", "0")); DDLFamilyRelationship3th.Items.Insert(1, new ListItem("父女", "0")); DDLFamilyRelationship3th.Items.Insert(2, new ListItem("母女", "0")); DDLFamilyRelationship3th.Items.Insert(3, new ListItem("夫妻", "0")); DDLFamilyRelationship3th.Items.Insert(4, new ListItem("兄妹", "0")); DDLFamilyRelationship3th.Items.Insert(5, new ListItem("姐弟", "0")); DDLFamilyRelationship4th.Items.Insert(1, new ListItem("父女", "0")); DDLFamilyRelationship4th.Items.Insert(2, new ListItem("母女", "0")); DDLFamilyRelationship4th.Items.Insert(3, new ListItem("夫妻", "0")); DDLFamilyRelationship4th.Items.Insert(4, new ListItem("兄妹", "0")); DDLFamilyRelationship4th.Items.Insert(5, new ListItem("姐弟", "0")); } else { DDLFamilyRelationship2nd.Items.Insert(0, new ListItem("-请选择-", "0")); } } }
string[] arr = new string[0] { };if (DDLSex.Text == "男"){ arr = new[] { "-请选择-", "父子", "母子", "夫妻", "兄妹", "姐弟" };}else if (DDLSex.Text == "女"){ arr = new[] { "-请选择-", "父女", "母女", "夫妻", "兄妹", "姐弟" };}else{ //..}DDLFamilyRelationship1st.DataSource = arr;DDLFamilyRelationship1st.DataBind();DDLFamilyRelationship2nd.DataSource = arr;DDLFamilyRelationship2nd.DataBind();DDLFamilyRelationship3th.DataSource = arr;DDLFamilyRelationship3th.DataBind();DDLFamilyRelationship4th.DataSource = arr;DDLFamilyRelationship4th.DataBind();