我将infragistics webcombo
与typeahead suggest
一起使用。
问题在于,我可以使用WebCombo1_InitializeDataSource
与xmlReq
联系,但数据在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 :(得分:0)
您只需设置webcombo
的以下属性:
EnableXmlHTTP="True"
Editable="True"
ComboTypeAhead="Suggest"
将web组合与webcombo的InitializeDataSource
事件中的数据源绑定
并在page_load
为真时绑定page.ispostback
中的webcombo。
在您的存储过程中实施搜索逻辑,例如select * from employee where emp_name like 'a%'
。
这将在你输入数据时检索记录。