有两种方法:一种是用dual表查空值,然后绑定。另一种是先动态绑定数据后,然后插入一列默认项。

eg1:
string selectQuery = "select  null extattrid,null extattrname from dual union all select  extattrid,extattrname from VExtAttrDetail where extattrsn in (22)";
     DataSet ds=dboperReq.GetDSet(selectQuery);
    ddlTrantype.DataTextField = "extattrname";
    ddlTrantype.DataValueField="extattrid";
    ddlTrantype.DataSource=ds.Tables[0].DefaultView;
    ddlTrantype.DataBind();

eg2:
 string selectQuery = "select  extattrid,extattrname from VExtAttrDetail where extattrsn in (22)";
    DataSet ds=dboperReq.GetDSet(selectQuery);
    ddlTrantype.DataTextField = "extattrname";
    ddlTrantype.DataValueField="extattrid";
    ddlTrantype.DataSource=ds.Tables[0].DefaultView;
    ddlTrantype.DataBind();
    ddlTrantype.Items.Insert(0,new ListItem(" "," ")); //或者ListItem it = new ListItem("请选择", "0");
//mydroplist.Items.Insert(0,it);     或者 ListItem lt = new ListItem();
//lt.Text = "请选择";
//lt.Value = "00";
//lt.Selected = true;
//ddp.Items.Add(lt);

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-08-14
  • 2022-12-23
  • 2021-08-22
  • 2021-10-24
  • 2022-02-15
  • 2022-02-18
猜你喜欢
  • 2021-12-17
  • 2021-11-02
  • 2021-06-22
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-05
相关资源
相似解决方案