2013-04-30 37 views
0

在我的应用程序中有复选框的网格视图,选择多个复选框单击打印按钮在单独的窗口中打开pdf。 我的代码是如何使用asp.net在新窗口中打开多个pdf文件

for (int i = 0; i < grdAdditionalInsured.Rows.Count; i++) 
{ 
    CheckBox chk = (CheckBox)grdAdditionalInsured.Rows[i].Cells[0].FindControl("chkAdditionalInsured"); 

    if (chk.Checked == true) 
    { 
     //**some code to get the id based on values** 
     string file = "/CertPrints/" + id.ToString() + ".pdf"; 
     String js = @"WindowPopup('" + file + "');"; 
     ScriptManager.RegisterStartupScript(this, this.GetType(), file, js, true); 
    } 
} 

上面的代码只显示最后一个记录pdf文件,请给我建议。

+0

感谢并接受了投票非常感谢! – bUKaneer 2013-04-30 11:12:21

回答

1

试试这个:

StringBuilder js = new StringBuilder(); 
for (int i = 0; i < grdAdditionalInsured.Rows.Count; i++) 
{ 
    bool checked = ((CheckBox)grdAdditionalInsured.Rows[i].Cells[0].FindControl("chkAdditionalInsured")).Checked; 
    if (checked) 
    { 
     //**some code to get the id based on values** 
     js.AppendFormat(@"WindowPopup('/CertPrints/{0}.pdf');",id)); 
    } 
} 
ScriptManager.RegisterStartupScript(this, this.GetType(), "filePopup", js.ToString(), true); 
+0

嗨。 我正在试着此代码。它创造奇迹。唯一的问题是,加载所有弹出窗口后,我的主页是空的。如何在弹出窗口打开后正确加载主页面。 – jitendragarg 2015-03-13 14:03:44

相关问题