使用javascript和jquery将选定的行从一个gridview传输到另一个gridview [英] Transfer selected rows from one gridview to another using javascript and jquery

查看:64
本文介绍了使用javascript和jquery将选定的行从一个gridview传输到另一个gridview的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我得到以下代码创建两个GriViews,第一个GridView用于显示细节,第二个用于在单击CheckBoxes时显示行。



protected void Page_Load(object sender,EventArgs e)

{

if(!this.IsPostBack)

{

DataTable dt = new DataTable();

dt.Columns.AddRange(new DataColumn [5] {new DataColumn(itemcode,typeof(int)),

new DataColumn(itemname,typeof(string)),

new DataColumn(unit,typeof(string)),

new DataColumn(price,typeof (字符串)),
新的DataColumn(stock_qty,typeof(string))});

dt.Rows.Add(1,Android Phone, Nos,30000,50);

dt.Rows.Add(2,Iphone,Nos,50000,20);

dt .Rows.Add(3,Samsung pohne,Nos,40000,15);

GridView1.DataSource = dt;

GridView1.DataBind ();

GridView2.DataSource = null;

GridView2.DataBind();

}

}



我尝试了什么:



但是,我想修改用于从SQL数据库获取数据的代码。因此,我想使用以下代码修改上述代码,以使用存储过程ID从数据库获取数据,如下所示:



I got the following code create two GriViews and first GridView is used to show the details and the second one is used to display the rows when clicking CheckBoxes.

protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
DataTable dt = new DataTable();
dt.Columns.AddRange(new DataColumn[5] { new DataColumn("itemcode", typeof(int)),
new DataColumn("itemname", typeof(string)),
new DataColumn("unit", typeof(string)),
new DataColumn("price", typeof(string)),
new DataColumn("stock_qty",typeof(string)) });
dt.Rows.Add(1, "Android Phone", "Nos", "30000", "50");
dt.Rows.Add(2, "Iphone", "Nos", "50000", "20");
dt.Rows.Add(3, "Samsung pohne", "Nos", "40000", "15");
GridView1.DataSource = dt;
GridView1.DataBind();
GridView2.DataSource = null;
GridView2.DataBind();
}
}

What I have tried:

But, i would like modify the code to get the data from SQL database.Hence, i want to modify above code with following codes to get data from Database using Stored procedure id as follows:

public void GetItems()
        {
            DataSet ds1 = new DataSet();
            D.id = 2; // select * from ItemTable
            ds1 = C.DATA1(D);
            GridView1.DataSource = ds1.Tables[0];
            GridView1.DataBind();
            GridView2.DataSource = null;
            GridView2.DataBind();

        }

推荐答案

就像你说的那样,你想在Store程序的帮助下绑定Gridview,请参考

将数据绑定到ASP。使用存储过程的Net GridView [ ^ ]
Like you said, you want to bind Gridview with the help of Store procedure, please refer
Bind data to ASP.Net GridView using Stored Procedure[^]


这篇关于使用javascript和jquery将选定的行从一个gridview传输到另一个gridview的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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