标签:htm tail etl ddl detail repo abi col null
private void BindGoodName(DropDownList ddlGoodsName) { string sqlwhere = string.Empty; if (!string.IsNullOrEmpty(Request["id"])&& Convert.ToInt32(Request["id"]) > 0) { sqlwhere = " and Id <> " + Convert.ToInt32(Request["id"]); } ddlGoodsName.DataSource = goods.GetList(" g.GoodsID not in (select GoodsId from CRM_IntegralRule where TypeId=3 "+ sqlwhere + " and RuleType=1)"); ddlGoodsName.DataTextField = "GoodsName"; ddlGoodsName.DataValueField = "GoodsId"; ddlGoodsName.DataBind(); ddlGoodsName.Items.Insert(0, new ListItem(Resources.Admin.Item_PleaseSelect, "")); }
设定下拉项被选中
ListItem x = ddlGoodsName.Items.FindByValue(model.GoodsId.Value.ToString());
if (x != null) x.Selected = true;
一、在绑定数据源后,设置选中的值 (1) dropdowslist.selectedIndex=索引值(数字); (2) dropdownlist.Items.findbyvalue(你的值).selected=true (3) dropdownlist.Items.findbytext(你的值).selected=true
asp.net页面中,如下方法给DropDownList赋值: dpType.SelectedIndex = dpType.Items.IndexOf(dpType.Items.FindByText(m_TradeReport.R_CateName)); 或 dpType.SelectedIndex = dpType.Items.IndexOf(dpType.Items.FindByValue(m_TradeReport.R_CateID)); 这两个可以避免以下方法有时候不能设置值的情况: dpType.SelectedValue = Convert.ToString(m_TradeReport.R_CateID);
参考:https://blog.csdn.net/wangganggang90/article/details/8468027
https://www.cnblogs.com/downmoon/archive/2011/03/28/1998077.html
标签:htm tail etl ddl detail repo abi col null
原文地址:https://www.cnblogs.com/shy1766IT/p/12355490.html