Infragistics webcombo Typeahead建议

时间:2009-07-30 11:06:02

标签: asp.net infragistics webcombo

我将infragistics webcombotypeahead suggest一起使用。

问题在于,我可以使用WebCombo1_InitializeDataSourcexmlReq联系,但数据在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;        
}

1 个答案:

答案 0 :(得分:0)

您只需设置webcombo的以下属性:

即可实现此目的
EnableXmlHTTP="True" 
Editable="True"
ComboTypeAhead="Suggest"

将web组合与webcombo的InitializeDataSource事件中的数据源绑定 并在page_load为真时绑定page.ispostback中的webcombo。

在您的存储过程中实施搜索逻辑,例如select * from employee where emp_name like 'a%'

这将在你输入数据时检索记录。