Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
555
WebDropDown DataBinding Issue
posted

Hi, I am using WebDropDown (WDD) to perform a TypeAhead search. I have 10000 records in the database. On page load, I retireve only first 20 records (to avoid the performace hit on the page) and bind it to the WDD. When the user types any text into the WDD, my objective is to search for matching records in the database and re-bind the filtered matching results to the WDD so user can select from the filtered results.

I used the following approach to populate the data into the WDD...

<ig:WebDropDown ID="igSearchCombo" runat="server" Width="400px"
DisplayMode="DropDown" EnableCustomValues="true" AutoSelectOnMatch="false"
AutoFilterQueryType="Contains" EnableLoadOnDemand="true"
EnableAutoCompleteFirstMatch="false" EnableAutoFiltering="Server"
ValueField="accountid" TextField="name" DataKeyFields="id">
<ClientEvents InputKeyUp="igSearchCombo_InputKeyUp" />
</ig:WebDropDown>

function igSearchCombo_InputKeyUp(sender, eventArgs)
{
    //debugger;
    var webCombo = sender.get_id();
    var newValue = sender.get_previousValue();

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

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

In the code-behind, I use the following to bind the resultset to WDD.

protected void Page_Load(object sender, EventArgs e)
{
string searchStr = Request.QueryString["query"];

using (MyConnection)
{
    if (searchQry != null)
    {
        query = "SELECT top 20 name, id FROM MyTable WHERE name like '" + searchStr + "%' ORDER BY name ASC";
    }

    SqlCommand myCommand = new SqlCommand(query, myConnection);
    myCommand.CommandTimeout = 120;
    myCommand.CommandType = CommandType.Text;

    SqlDataAdapter myAdapter = new SqlDataAdapter();
    myAdapter.SelectCommand = myCommand;
    myAdapter.Fill(MyDataTable);
    myAdapter.Dispose();
}
igSearchCombo.DataSource = dtRelationships;
igSearchCombo.DataBind();
}

Issue:
1. When entering text into the WDD, I see my code-behind code is called and new resultset is retrived, but it does not rebind to the WDD. The WDD still shows old data i.e. first 20 records bound on initial load which gets filtered matching to the entered text. Can someone please suggest what am I doing wrong?
2. In the clientside API, in keyUp event, when I check the sender.get_currentValue(), I do not get the currently entered text..it always returns undefined. Whereas, the sender.get_previousvalue() shows the just previous text typed into the WDD. Since the event is fired on each keyup, the previousText is always one character less than the current search query. Is this a bug with sender.get_currentValue()?

Parents Reply Children
No Data