积极答复者
动态加载控件的问题

问题
答案
-
DropDownList DropDownList1 = (DropDownList)Panel1.FindControl("DropDownList1"); // DropDownList1 是你 DropDownList控件的IDDropDownList DropDownList2 = (DropDownList)Panel1.FindControl("DropDownList2");你还可以通过,下面的方式获取DropDownList DropDownList1 = (DropDownList)Panel1.Controls[0];DropDownList DropDownList2 = (DropDownList)Panel1.Controls[1];
知识改变命运,奋斗成就人生!2009年8月28日 4:36版主
全部回复
-
DropDownList DropDownList1 = (DropDownList)Panel1.FindControl("DropDownList1"); // DropDownList1 是你 DropDownList控件的IDDropDownList DropDownList2 = (DropDownList)Panel1.FindControl("DropDownList2");你还可以通过,下面的方式获取DropDownList DropDownList1 = (DropDownList)Panel1.Controls[0];DropDownList DropDownList2 = (DropDownList)Panel1.Controls[1];
知识改变命运,奋斗成就人生!2009年8月28日 4:36版主 -
我是这样写的:
DropDownList dropdownlist1 = sender as DropDownList; DropDownList dropdownlist2 = (DropDownList)Panel1.Controls[10]; dropdownlist2.Items.Remove(dropdownlist1.SelectedValue);
运行后如果第一次选中DropDownList1 的值2,则DropDownList2 中只剩下1,3,但是第二次选中DropDownList1 的值1,则DropDownList2 中只剩下3,为什么,如何修改呀?2009年8月28日 5:47 -
如果DropDownList1 和DropDownList2 得内容一样,如都是:
DropDownList1 的值: DropDownList2 的值
1 1
2 2
3 3
选中DropDownList1 的值2,则DropDownList2 中只剩下1,3.如果选中DropDownList1 的值1,则DropDownList2 中只剩下2,3,这样写:
DropDownList dropdownlist2 = (DropDownList)Panel1.Controls[10];
//清除dropdownlist2的值
dropdownlist2.Items.Clear();
//将dropdownlist1得值赋值给dropdownlist2的值
for (int i = 0; i < dropdownlist1.Items.Count; i++)
{
dropdownlist2.Items.Add(dropdownlist1.Items[i].ToString());
}
//在dropdownlist2中删除dropdownlist1中选择的
dropdownlist2.Items.Remove(dropdownlist1.SelectedValue);
可以实现只有一组控件,如何修改才能实现动态添加多组后,每组都能实现上面的功能???2009年8月28日 8:28