簡體   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