C# codeprotected 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")); } } }