我在typeahead suggest中使用infragistics webcombo。
问题是我可以使用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;
}发布于 2009-07-31 12:05:21
只需设置webcombo的以下属性即可实现此目的
EnableXmlHTTP="True"
Editable="True"
ComboTypeAhead="Suggest"并将该网页组合与该网页组合的InitializeDataSource事件中的数据源进行绑定,当page.ispostback为真时,还将该网页组合绑定到该page_load中。
在你的存储过程中实现搜索逻辑,例如select * from employee where emp_name like 'a%'。
这将在您键入数据时检索记录。
https://stackoverflow.com/questions/1205897
复制相似问题