日期:2014-05-18  浏览次数:20768 次

combobox加入请选择
C#版中的combobox 

  cbbTempList.DataSource = BLL.CommonUtinl.GetTempByUserId(string.Format(" RF_User_Id={0} and Template_CreateTime='{1}'",this.loginUserID,"6"));
   
  this.cbbTempList.Items.Insert(-1,"请选择"); 为何这句会报错?
  cbbTempList.ValueMember = "Id";
  cbbTempList.DisplayMember = "Template_Name";
  this.cbbTempList.SelectedIndex = -1;

------解决方案--------------------
而且你的程序顺序好像错了吧~
C# code

cbbTempList.ValueMember = "Id";
cbbTempList.DisplayMember = "Template_Name";
cbbTempList.DataSource = BLL.CommonUtinl.GetTempByUserId(string.Format(" RF_User_Id={0} and Template_CreateTime='{1}'",this.loginUserID,"6"));
this.cbbTempList.Items.Insert(0,"请选择"); 
 this.cbbTempList.SelectedIndex = 0;

------解决方案--------------------
this.cbbTempList.Items.Insert(0,"请选择");
------解决方案--------------------
this.cbbTempList.Items.Insert(0,"请选择");放最前面
------解决方案--------------------
探讨

没有搞定。。。。。。。。。。。。

------解决方案--------------------
在绑定之前对数据源insert(),这样就可以放在最前了