Optimize response time in Ajax

Posted by Riyazhaider under ASP.NET AJAX on 12/13/2013 | Points: 10 | Views : 1569 | Status : [Member] | Replies : 2
I have a query form and on selection of 1 combo 6 combo get records on the basis of selection in first combo( i m using java-script to populate values through ajax). I optimize the ajax working and solution was working fine when i upload it on web (Windows server 2005) then there was no change in response time on selection of first combo.
What may the reason that solution that is working on local machine , not working on web.




Responses

Posted by: vishalneeraj-24503 on: 12/13/2013 [Member] [MVP] Platinum | Points: 25

Up
0
Down
Are you hitting db on every dropdown selectedindexchanged? if yes. then what you have to do.
Please store your data in viewstate. and on selectedindexchanged event,fill other dropdownlists from your viewstate based on the selected value.

You can use dataset/datatable Select method.
So it's one time activity to store all your data in viewstate in page load.
And with the help of Select method,you can pass values.

protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
DataTable dt = new DataTable();
dt.Columns.Add("Id");
dt.Columns.Add("Name");

dt.Rows.Add("1", "Vishal");
dt.Rows.Add("2", "Rajesh");
dt.Rows.Add("3", "Prashant");
dt.Rows.Add("4", "Dharmesh");
dt.Rows.Add("5", "Nitin");


DropDownList1.DataSource = dt;
DropDownList1.DataTextField = "Name";
DropDownList1.DataValueField = "Id";
DropDownList1.DataBind();

ViewState["DataTeable"] = dt;
}
}

protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
try
{
DropDownList2.Items.Clear();
if (ViewState["DataTeable"] != null)
{
DataTable dt = (DataTable)ViewState["DataTeable"];
if (dt != null)
{
if (dt.Rows.Count > 0)
{
DataRow[] dr = dt.Select("Id='" + DropDownList1.SelectedValue + "'");
if (dr != null)
{
if (dr.Length > 0)
{
DataTable dt_new = dr.CopyToDataTable();
DropDownList2.DataSource = dt_new;
DropDownList2.DataTextField = "Name";
DropDownList2.DataValueField = "Id";
DropDownList2.DataBind();
}
}
}
}
}
}
catch (Exception ex)
{
throw ex;
}
}


Riyazhaider, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: vishalneeraj-24503 on: 12/13/2013 [Member] [MVP] Platinum | Points: 25

Up
0
Down

Hi Riyazhaider,
please let me know.

Riyazhaider, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response