2009-07-30 57 views
0

我使用infragistics webcombotypeahead suggestInfragistics webcombo Typeahead建議

問題是我能夠使用xmlReq達到WebCombo1_InitializeDataSource,但數據在webcombo中不可見。

下面是一段代碼,我使用:

<igcmbo:WebCombo ID="WebCombo1" runat="server" EnableXmlHTTP="True" Editable="True" 
          ComboTypeAhead="Suggest"> 
          <Columns>        
          <ClientSideEvents EditKeyUp="WebCombo1_EditKeyUp"> 
          </ClientSideEvents> 
         </igcmbo:WebCombo>        

JavaScript函數:

function WebCombo1_EditKeyUp(webComboId,newValue,keyCode) 
    { 
     var oWebCombo1=igcmbo_getComboById(webComboId) 

     xmlReq = null; 
     if(window.XMLHttpRequest) xmlReq = new XMLHttpRequest(); 
      else if(window.ActiveXObject) xmlReq = new ActiveXObject("Microsoft.XMLHTTP");       

     var search=newValue&&newValue.length&&newValue.length>0?newValue:"";       
     xmlReq.open("GET","ActivityManagement.aspx?searchString="+search,true);  
     xmlReq.send(null); 
    } 

後面的代碼:

void WebCombo1_InitializeDataSource(object sender, Infragistics.WebUI.WebCombo.WebComboEventArgs e) 
{ 
    string str = ""; 
    if (this.Request.QueryString["searchString"] != null) 
    { 
     str = this.Request.QueryString["searchString"].ToUpper(); 
    } 
    else str = "00"; 
    DataTable dtProducts = OperationsDataAccess.GetProductList(str); 
    string rowFilter = "DeleteFlag = 0"; 
    dtProducts.DefaultView.RowFilter = rowFilter; 
    WebCombo1.DataSource = dtProducts.DefaultView; 
    WebCombo1.DataTextField = "Name"; 
    WebCombo1.DataValueField = "Id"; 
    WebCombo1.DataBind(); 
    WebCombo1.DropDownLayout.RowSelectors = RowSelectors.No;   
} 

回答

0

您可以通過簡單的設置實現這一目標以下webcombo的性質:

EnableXmlHTTP="True" 
Editable="True" 
ComboTypeAhead="Suggest" 

,並綁定與數據源的網絡組合在InitializeDataSource事件webcombo 的,也結合在page_load的webcombo當page.ispostback是真實的。

在存儲過程中實現搜索邏輯,例如select * from employee where emp_name like 'a%'

這將在您記錄數據時檢索記錄。

相關問題