Client Side events and Server side binding

I want to filter a dataset, server side and bind it to a select control. Problem is my filtering must be done based on the text written by the user in a text input. To get this text i'm using client side keyboard events.

I tried to use client side binding and it works fine, but the problem is my dataset has more than 10000 rows, and so the performance is awful. Only thing i can do i think is to rebind the select control to a filtered dataset, improving performance. This is my code at the moment:

In the aspx:

static

HtmlSelect _control = null;

[

WebMethod(EnableSession = true)]

public static void SetData(DataTable result)

{

HtmlSelect control = _control;

control.DataSource = result.DataSet;

control.DataMember =

"campaigns";

control.DataTextField =

"name";

control.DataValueField =

"id_campaign";

control.DataBind();

}

JavaScript:

function

Filtering(textBox)

{

FilterData.GetData(textBox.value, OnDataRequestComplete);

}

 

function OnDataRequestComplete(result)

{

PageMethods.SetData(result);

var RsltElem = document.getElementById("Results");

RsltElem.innerHTML =

"Done";

}

 

In The WebService FilterData:

[

WebMethod(EnableSession = true)]

public DataTable GetData(string filter)

{

DataSet ds1 = new DataSet();

DataSet result = new DataSet();

if (Session != null && Session["DataSet"] != null)

ds1 = (

DataSet)Session["DataSet"];

else

{

ds1.ReadXml(

"c:\\t.xml", XmlReadMode.InferSchema);

Session[

"DataSet"] = ds1;

}

if (String.IsNullOrEmpty(filter))

filter =

String.Empty;

DataRow[] rows = ds1.Tables[0].Select("name LIKE '*" + filter + "*'", "name asc");

result.Merge(rows);

return result.Tables[0];

}

 

I have a javascript exception "PageMethods is not defined" can anyone help me with this one? Thanks

0
rumbafum
11/7/2006 6:18:12 PM
📁 asp.net.networking-webservices
📃 2181 articles.
⭐ 0 followers.

💬 0 Replies
👁️‍🗨️ 1826 Views

Reply: