2013-01-03 67 views
0

下拉ignors默認的行添加到列表jqGrid的,下拉沒有添加defaul值

.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

// DropdownBox

我需要所有添加的過濾,但由於某種原因,如果我d o在.CS數據綁定文件,它省去了[ALL]

+0

保護無效的Page_Load(對象發件人,EventArgs的) 後{ 如果 { 如果(CheckEmployee()){ 如果 (gvSaleView.AjaxCallBackMode == AjaxCallBackMode.None) { LoadProduct()(的IsPostBack!); } } } InitializeGridSettings(); } – user1944677

回答

0

我應該叫ddlProduct.DataBind();你都添加到列表Items

if (objProduct != null) 
{ 

    ddlProduct.DataSource = objProduct; 
    ddlProduct.DataValueField = "ProductCode"; 
    ddlProduct.DataTextField = "ProductCode"; 

} 

ddlProduct.Items.Insert(0, new ListItem(DropDownListText, DropDownListValue)); 
ddlProduct.DataBind();