需要在网格视图中的新窗口中打开输出
本文关键字:窗口 输出 新窗口 网格 视图 | 更新日期: 2023-09-27 18:36:31
嗨,在下面的按钮上单击代码。我需要在网格视图中的新窗口中打开输出。下面是按钮单击的代码。
protected void Button3_Click(object sender, EventArgs e)
{
DataTable dt = new DataTable();
dt.Columns.AddRange(new DataColumn[21] { new DataColumn("Siebel_SR#"), new DataColumn("Siebel_SR#1"), new DataColumn("Tran_Qty"), new DataColumn("Ord_Sou_Ref"), new DataColumn("Tran_Reference"), new DataColumn("[Ord Number]"), new DataColumn("[Ord Number1]"), new DataColumn("Transaction_Type_Id"), new DataColumn("Trans_Date"), new DataColumn("[Trans Sub]"), new DataColumn("Business"), new DataColumn("New_DFF_SR#"), new DataColumn("Reason_Name"), new DataColumn("Line_Type"), new DataColumn("Org"), new DataColumn("Sub_Inv"), new DataColumn("Part_Num"), new DataColumn("[Last Updated By]"), new DataColumn("[Created By]"), new DataColumn("Employee"), new DataColumn("DateWorked") });
foreach (GridViewRow row in GridView1.Rows)
{
if (row.RowType == DataControlRowType.DataRow)
{
CheckBox chk = (row.Cells[0].FindControl("chkSelect") as CheckBox);
if (chk.Checked)
{
string Siebel_SR = row.Cells[1].Text;
string Siebel_SR1 = row.Cells[2].Text;
string Tran_Qty = row.Cells[3].Text;
string Ord_Sou_Ref= row.Cells[4].Text;
string Tran_Reference = row.Cells[5].Text;
string Ord_Number = row.Cells[6].Text;
string Ord_Number1 = row.Cells[7].Text;
string Transaction_Type_Id = row.Cells[8].Text;
string Trans_Date = row.Cells[9].Text;
string Trans_Sub = row.Cells[10].Text;
string Business = row.Cells[11].Text;
string New_DFF_SR = row.Cells[12].Text;
string Reason_Name = row.Cells[13].Text;
string Line_Type = row.Cells[14].Text;
string Org = row.Cells[15].Text;
string Sub_Inv = row.Cells[16].Text;
string Part_Num = row.Cells[17].Text;
string Last_Updated_By = row.Cells[18].Text;
string Created_By = row.Cells[19].Text;
string Employee = row.Cells[20].Text;
string DateWorked = row.Cells[21].Text;
dt.Rows.Add(Siebel_SR , Siebel_SR1 , Tran_Qty ,Ord_Sou_Ref , Tran_Reference , Ord_Number , Ord_Number1 , Transaction_Type_Id , Trans_Date , Trans_Sub , Business , New_DFF_SR ,Reason_Name ,Line_Type , Org , Sub_Inv , Part_Num , Last_Updated_By , Created_By , Employee , DateWorked );
}
}
}
GridView3.DataSource = dt;
GridView3.DataBind();
}
如果我理解正确 - 您需要在新窗口中显示新网格 (GridView3)。如果是这样 - 创建一个新的 ASPX 页面,说"输出.aspx"并在那里添加 GridView3 而不是当前页面。
然后在当前代码中,而不是绑定网格的最后 2 行 - 将新创建的数据表存储在会话中:
Session["GridView3Data"] = dt;
并打开您的新页面:
ScriptManager.RegisterStartupScript(this, this.GetType(), "open", "winodw.open('Output.aspx');", true);
在 Output 的 pageload 事件中.aspx.cs读取该会话变量并将其绑定到 grd:
DataTable dt = (DataTable)Session["GridView3Data"];
GridView3.DataSource = dt;
GridView3.DataBind();