下拉菜单忽略将默认行添加到列表
。CS
private const string DropDownListValue = "[All]";
private const string DropDownListText = "[All]";
private void LoadProduct()
{
try
{
FieldGoalEntities objEntity = new FieldGoalEntities();
IQueryable<Product> objProduct = from p in objEntity.Product
select p;
ddlProduct.Items.Clear();
if (objProduct != null)
{
ddlProduct.DataSource = objProduct;
ddlProduct.DataValueField = "ProductCode";
ddlProduct.DataTextField = "ProductCode";
ddlProduct.DataBind();
}
ddlProduct.Items.Insert(0, new ListItem(DropDownListText, DropDownListValue));
}
catch (Exception ex)
{
Common.LogEvent(Common.LoggingType.Error, "LoadProduct", ex.Message);
Common.ShowMessageBox(this.Master, "Error", "Load Product Status: " + ex.Message);
}
}
//ASPX
//下拉框
我需要为过滤添加所有内容,但由于某种原因,如果我在 .CS 文件中进行数据绑定,它会忽略 [ALL]