DropDownList 怎么绑定数据
2016-06-08
展开全部
有两种方法:一种是用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);
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);
Storm代理
2023-07-25 广告
2023-07-25 广告
StormProxies是一家国内优质海外HTTP代理商,拥有一个庞大的IP资源池,覆盖200多个地区,IP数量大且匿名度高。其优点还包括超高并发、稳定高效、技术服务等特点,同时提供HTTP、HTTPS以及SOCKS5协议支持。此外,Sto...
点击进入详情页
本回答由Storm代理提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询