50分求助:combox如何添加数据库

yixian2007 2009-03-26 04:28:40
绑定数据库,偶是会的.

但是我想加一项,叫"全部"

比如,数据库表中有2007,2008,2009年三行,我读取出来的下拉框,也只有三行,我想在最上面多加一行,叫全部,请问怎么做?
...全文
113 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
wensen1232 2009-03-26
  • 打赏
  • 举报
回复
[Quote=引用 8 楼 liu4545533 的回复:]
手动在combox加一项“全部”然后当combox选择全部项的时候做逻辑判断
[/Quote]

支持 此举最简单!
liu4545533 2009-03-26
  • 打赏
  • 举报
回复
手动在combox加一项“全部”然后当combox选择全部项的时候做逻辑判断
xue5ya 2009-03-26
  • 打赏
  • 举报
回复
select '全部'
union all
select *
from table A

然后把查询出的结果dataset
赋给this.DropDownListCityType.DataSource
编程有钱人了 2009-03-26
  • 打赏
  • 举报
回复

private void InitCityType()
{
this.DropDownListCityType.Items.Clear();
this.DropDownListCityType.DataTextField = "CITY_TYPE_NAME";
this.DropDownListCityType.DataValueField = "CITY_TYPE";
this.DropDownListCityType.DataSource = DicClass.GetCityList(int.Parse(this.DropDownListProvinceType.SelectedValue));
this.DropDownListCityType.DataBind();
this.DropDownListCityType.Items.Add(new ListItem("--选择全部--", "-1"));
this.DropDownListCityType.SelectedIndex = this.DropDownListCityType.Items.Count - 1;
}
xue5ya 2009-03-26
  • 打赏
  • 举报
回复
理解错了
luckapple2 2009-03-26
  • 打赏
  • 举报
回复
combox.child.add("全部");
数据库项
贫僧又回来了 2009-03-26
  • 打赏
  • 举报
回复
忘记了,可以实现的
你绑定的时候有没有用dispalymember和dispalaymember?
贫僧又回来了 2009-03-26
  • 打赏
  • 举报
回复
绑定数据库后没办法修改值
你直接this.comboBox1.SelectedIndex = -1;
这样默认为空
xue5ya 2009-03-26
  • 打赏
  • 举报
回复
SELECT "全部",*
FROM TABLE A

111,126

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Creator Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧