Click here to Skip to main content
15,888,803 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi guys,

I have asp.net website in c#.

I have one page, in which i have a table in this table i have,
dropdownlist, text boxes, labels and one 'add button'.

This add button will the table data to the Repeater in C#.

Code:
protected void btnAddTransport_Click(object sender, EventArgs e)
    {
        DataTable dt;
        try
        {
            if (ddlsch.SelectedIndex > 0)
            {
                if (MySession.Current.Tr_TempDataTable == null)
                {
                    dt = new DataTable();
                    dt.Columns.Add("RefID", typeof(string));
                    dt.Columns.Add("sch", typeof(string));
                    dt.Columns.Add("qty", typeof(string));
                    dt.Columns.Add("mileage", typeof(string));
                    dt.Columns.Add("trips", typeof(string));
                    dt.Columns.Add("unitprice", typeof(string));
                    dt.Columns.Add("description", typeof(string));
                    dt.Columns.Add("netprice", typeof(string));
                }
                else
                {
                    dt = MySession.Current.Tr_TempDataTable;
                }

                DataRow dr = dt.NewRow();
                dr["RefID"] = ddlsch.SelectedValue.ToString();
                dr["sch"] = ddlsch.SelectedItem.ToString();
                dr["qty"] = txtQuantity.Text;
                dr["mileage"] = txtmileage.Text;
                dr["trips"] = txttrips.Text;
                dr["unitprice"] = lbltunitprice.Text;
                dr["description"] = hdndesc.Value.ToString();
                dr["NetPrice"] = hdntNP.Value.ToString();
                dt.Rows.Add(dr);
                MySession.Current.Tr_TempDataTable = dt;
                Repeater1.DataSource = dt;
                Repeater1.DataBind();

                ddlsch.ClearSelection();
                txtQuantity.Text = "";
                txtmileage.Text = "";
                txttrips.Text = "";
                lbltunitprice.Text = "";
                lbldesc.Text = "";
                hdntNP.Value = "";

            }
        }
        catch (Exception)
        {

            throw;
        }

    }


I have published this code on client server. N on the server it is taking more than or
equal to 4sec.

So, i want to do this in Ajax/Javascript/JQuery to bind the repeater.

Can any one plz help me.

Thanks
Posted
Updated 31-May-15 20:26pm
v2

1 solution

Binding data to a server control using jQuery Ajax is not a good idea. You have two better options.

1. UpdatePanel with the Repeater
2. Using some other client side controls like jQGrid or something.

If you still want to do it, please check the answer in this thread - how can i bind asp.net datalist using jquery json and webservice.[^].
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900