不能在 DropDownList 中选择多个项
請教各位前輩如何解決:不能在 DropDownList 中选择多个项的問題?以盼為謝!代碼如下:
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
ini_money();
ini_info();
}
}
protected void ini_money()
{
List<Mmoney> ml = new Bmoney().GetModelList(" 1=1");
foreach (Mmoney m in ml)
{
ListItem li = new ListItem(m.money_type, m.money_id.ToString());
DDmoney.Items.Add(li);
DDmoney2.Items.Add(li);
DDmj_money.Items.Add(li);
}
DDmoney.DataBind();
DDmj_money.DataBind();
DDmoney2.DataBind();
}
protected void ini_info()
{
long gj_id = Convert.ToInt64(dbr.GetSingle("select gjjl_id from t_gjjl where cdgjtz_id=" + tz_id + ""));
gjjl gj = new Bgjjl().GetModel(gj_id);
DDmoney.ClearSelection();
DDmoney2.ClearSelection();
DDmj_money.ClearSelection();
Mmoney money = new Bmoney().GetModel(Convert.ToInt32(gj.gjjl_money));
Mmoney money2 = new Bmoney().GetModel(Convert.ToInt32(gj.gjjl_money2));
Mmoney mj_money = new Bmoney().GetModel(Convert.ToInt32(gj.gjjl_mj_money));
DDmoney.Items.FindByText(money.money_type).Selected = true;
DDmoney2.Items.FindByText(money2.money_type).Selected = true;
DDmj_money.Items.FindByText(mj_money.money_type).Selected = true;
} --------------------编程问答-------------------- DropDownList里可以嵌套TreeView
楼主可以研究一下 --------------------编程问答--------------------
--------------------编程问答--------------------
同时选中多个选项?试试ListBox。。。 --------------------编程问答-------------------- listbox listbox listbox listbox --------------------编程问答-------------------- DropDownList 怎么能选择多个呢?
自定义控件? js弹出层? listbox类似的控件也行 --------------------编程问答--------------------
--------------------编程问答-------------------- LZ的意思是他的程序报了“不能在 DropDownList 中选择多个项的問題”这个错误吧?
<select name="selectmore" size="3" id="selectmore" multiple>
<option value="0">多选1</option>
<option value="1">多选2</option>
<option value="2">多选3</option>
</select>(按住ctrl键多选)
“DDmoney.Items.FindByText(money.money_type).Selected = true;”
不要随便这样写,有可能在之前已经有其他item的selected属性为true了,除非你在之前保证其他所有item的selected都是false
--------------------编程问答-------------------- 学习一下 --------------------编程问答-------------------- 用输入框加DIV可模拟你想要的结果,另外为什么不用ListBox呢?
补充:.NET技术 , ASP.NET