繁体   English   中英

在Webform(ASP.NET)中将选定的行从一个GridView传输到另一个GridView

[英]Transfer selected rows from one GridView to another GridView in webform (ASP.NET)

我有两个Gridview控件。 在第一个示例中,我使用SQL绑定了存储过程中的数据,我想将选定的行从Gridview1导出到GridView2。

这是我的代码,用于绑定Gridview1的数据:

// Load the data of [Student_Registration] store procedured
// from SQL to gridview1
sqlcom.CommandType = CommandType.StoredProcedure;
sqlcom.CommandText = "Student_Registration";
sqlcom.Parameters.Add("@SSID", SqlDbType.Int).Value = Int32.Parse(LblSubjectStudyId.Text.Trim());
sqlcom.Connection = con;
try
{
    con.Open();
    GridView1.EmptyDataText = "No Records Found";
    GridView1.DataSource = sqlcom.ExecuteReader();
    GridView1.DataBind();
}
catch (Exception ex)
{
    throw ex;
}
finally
{
    con.Close();
    con.Dispose();
}

我怎样才能做到这一点?

好的,首先,您需要在模板模板中添加一个复选框控件,然后您必须在页面上放置一个导出按钮。

单击按钮后,使用选中项的值在网格视图中找到所有选定的行,然后将整个行转换为数据行并将其添加到表中。

现在将此数据表绑定到gridview源。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM