我是这样写的
if (DropDownList7.SelectedValue == "1")
{
DropDownList4.Items.Clear();
DropDownList4.Items[0].Text = "进出用能单位燃料的静态计量";
DropDownList4.Items[0].Value = "1";
DropDownList4.Items[1].Text = "进出用能单位燃料的动态计量";
DropDownList4.Items[1].Value = "2"; }
else
{
if (DropDownList7.SelectedValue == "2")
{
DropDownList4.Items.Clear();
DropDownList4.Items[0].Text = "进出用能单位有功交流电能计量";
DropDownList4.Items[0].Value = "3";
DropDownList4.Items[1].Text = "进出用能单位的直流电能计量";
DropDownList4.Items[1].Value = "4"; }
}
不对的地方请指正
if (DropDownList7.SelectedValue == "1")
{
DropDownList4.Items.Clear();
DropDownList4.Items[0].Text = "进出用能单位燃料的静态计量";
DropDownList4.Items[0].Value = "1";
DropDownList4.Items[1].Text = "进出用能单位燃料的动态计量";
DropDownList4.Items[1].Value = "2"; }
else
{
if (DropDownList7.SelectedValue == "2")
{
DropDownList4.Items.Clear();
DropDownList4.Items[0].Text = "进出用能单位有功交流电能计量";
DropDownList4.Items[0].Value = "3";
DropDownList4.Items[1].Text = "进出用能单位的直流电能计量";
DropDownList4.Items[1].Value = "4"; }
}
不对的地方请指正
ListItem li = new ListItem("", "");
DropDownList1.Items.Add(li); 这个也行