如何使用Ajax / Javascript / JQuery将数据绑定到Repeater [英] how to bind data to the Repeater using Ajax/ Javascript/ JQuery

查看:71
本文介绍了如何使用Ajax / Javascript / JQuery将数据绑定到Repeater的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我在c#中有asp.net网站。



我有一个页面,我在这张桌子上有一张桌子,

下拉列表,文本框,标签和一个添加按钮。



这个添加按钮将表数据传递给C#中的Repeater。



代码:

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;
        }

    }





我已在客户端服务器上发布此代码。服务器上的N超过或等于
等于4秒。



所以,我想在Ajax / Javascript / JQuery中执行此操作来绑定转发器。



任何人都可以帮助我。



谢谢



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

推荐答案

使用 jQuery Ajax 不是一个好主意。你有两个更好的选择。



1. UpdatePanel 使用 Repeater

2.使用其他一些客户端控件,如jQGrid或其他东西。



如果你还想这样做,请检查此主题中的答案 - 如何使用jquery json和webservice绑定asp.net datalist。 [ ^ ]。
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.[^].


这篇关于如何使用Ajax / Javascript / JQuery将数据绑定到Repeater的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆