Вопрос

In my application have grid view with check boxes, select multiple checkboxes click on print button open the pdfs in seperate windows. my code is

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);
    }
}

Above code show only last record pdf file, please give me suggestion .

Это было полезно?

Решение

Try this:

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);
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top