2016-05-25 11 views
0

Ich habe eine ASP.NET Anwendung und ich dynamisch erstellen mehrere Comboboxen mit AjaxControl Toolkit. Alle Kombinationsfelder sind mit Daten gefüllt, aber einige zeigen die Daten nicht. Hier ist mein Code:ASP.NET AjaxControlToolkit.ComboBox zeigt nicht seine Artikel

cbo = new AjaxControlToolkit.ComboBox(); 

cbo.ID = string.Format(CultureInfo.GetCultureInfo("fr-FR"), "cbo{0}", RemoveSpecialCharacters(filter.Key)); // filter.key is the name of the combo 
      cbo.AutoCompleteMode = AjaxControlToolkit.ComboBoxAutoCompleteMode.SuggestAppend; 
      cbo.AutoPostBack = true; 
      cbo.Visible = true; 
      cbo.MaxLength = 500; 

cbo.DataSource = GetFilterData2(requestId, filter.Key); // loads the data source with a list<string> 
      cbo.DataBind(); 
      cbo.ItemInserted += this.CboItemInserted; 
      this.cboFilters.Add(cbo); 
      li.Controls.Add(cbo); // combo is added to the list item 

, wenn ich meine HTML-Seite mit Chrome überprüfen, die ich für die Combo zu bekommen, die funktioniert:

<ul id="MainContent_cboScanner_cboScanner_OptionList" class="ajax__combobox_itemlist" style="visibility: hidden; z-index: 1000; overflow-x: hidden; overflow-y: auto; width: 213px; position: absolute; height: 464px; left: 334px; top: 242px; display: none;"> 

Und für die, die nicht seine Elemente nicht angezeigt:

<ul id="MainContent_cboEnvironnement_cboEnvironnement_OptionList" class="ajax__combobox_itemlist" style="display:none;visibility:hidden;"> 

Warum würde eine AjaxControlToolkit Combobox ihre Elemente nicht anzeigen, obwohl sie sie haben?

Antwort

0

Alle Comboboxen nach einem fehlerhaften Textfeld, das ein Leerzeichen in der ID hatte, zeigten seine Elemente nicht an. Ich habe die Remove-Spezialzeichen-Methode für alle Textfelder hinzugefügt und das Problem wurde behoben. Hier

ist, was ich hinzugefügt:

txt = new TextBox(); 
txt.ID = string.Format(CultureInfo.GetCultureInfo("fr-FR"), "txt{0}", RemoveSpecialCharacters(filter.Key)); 

Hier ist meine Methode:

private static string RemoveSpecialCharacters(string mystring) 
{ 
    return mystring.Trim().Replace(' ', '_').Replace("'", "_").Replace("(", string.Empty).Replace(")", string.Empty).Replace("/", string.Empty).Replace(@"\", string.Empty); 
}