在我的应用程序中有带有复选框的网格视图,选择多个复选框单击打印按钮在单独的窗口中打开pdfs。 我的代码是
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 :(得分: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);