Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3795088
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T13:01:49+00:00 2026-05-19T13:01:49+00:00

I want to print reports based on GridView checkbox. If 3 rows have been

  • 0

I want to print reports based on GridView checkbox. If 3 rows have been chosen, there should be 3 reports. My code is like this…

protected void btn_Print_Click(object sender, EventArgs e)
    {
        if (IsPostBack)
        {
            try
            {
                foreach (GridViewRow gvr in grdRV.Rows)
                {
                    RadioButton rbID = (RadioButton)gvr.FindControl("rbID") as RadioButton;

                    if (rbID != null && rbID.Checked)
                    {
                        string sID = grdRV.DataKeys[gvr.RowIndex].Value.ToString().Trim();

                        if (rbl_Print.SelectedValue == "0")
                        {
                            SMTP(sID);
                        }
                        else if (rbl_Print.SelectedValue == "1")
                        {
                            Material(sID);
                        }
                    }
                 }
            }
            catch (Exception ex)
            {
                Session["error"] = ex.Message;
                Response.Redirect("MessageBoard.aspx");
            }
        }
    }

private void Material(string sID)
    {            

        string querystring = "../pmis/Reports/RptRFQMatV.aspx?RFQNo=" + lblRFQNo.Text.ToString() + "&ID=" + sID;

        Random r = new Random();            
        string Script = "";
        Script += "<script language=JavaScript id='PopupWindow'>";
        Script += "confirmWin = window.open(' " + querystring + "','" + r.Next() + "','scrollbars=yes,resizable=1, width=960,height=500,left=50,top=130,status');";
        Script += "confirmWin.Setfocus()</script>";

        //ClientScript.RegisterStartupScript(typeof(string), "PopupScript", "PopupWindow");
        if (!ClientScript.IsClientScriptBlockRegistered("PopupWindow"))
            ClientScript.RegisterClientScriptBlock(typeof(string), "PopupWindow", Script);
    }

…but currently this code can print report the last row only.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T13:01:49+00:00Added an answer on May 19, 2026 at 1:01 pm

    I tested this and it does open the three windows, you’ll have to tweak it a bit by passing a list of selected IDs to Material, so that you call Material just once. Inside material in your string manipulation, after the following line,

    Script += "<script language=JavaScript id='PopupWindow'>";
    

    add a for loop that goes though the selected IDs and adds a window.open. So, the following lines should be in the for/foreach loop

    string querystring = "../pmis/Reports/RptRFQMatV.aspx?RFQNo=" + lblRFQNo.Text.ToString() + "&ID=" + sID;
    
    
    Script += "confirmWin = window.open(' " + querystring + "','" + r.Next() + "','scrollbars=yes,resizable=1, width=960,height=500,left=50,top=130,status');";
    

    and then the following lines follow and are outside the for loop.

    Script += "confirmWin.Setfocus()</script>";
    
            //ClientScript.RegisterStartupScript(typeof(string), "PopupScript", "PopupWindow");
            if (!ClientScript.IsClientScriptBlockRegistered("PopupWindow"))
                ClientScript.RegisterClientScriptBlock(typeof(string), "PopupWindow", Script);
    

    This is my example and works. Also, would be better if you use StringBuilder instead of string +=

            string Script = "";
            Script += "<script language=JavaScript id='PopupWindow'>";
            Script += "window.open('www.google.com.au', '1','scrollbars=yes,resizable=1, width=960,height=500,left=50,top=130,status');";
            Script += "window.open('www.yahoo.com','2','scrollbars=yes,resizable=1, width=960,height=500,left=50,top=130,status');";
            Script += "window.open('www.stackoverflow.com','3', 'scrollbars=yes,resizable=1, width=960,height=500,left=50,top=130,status');";
            Script += "</script>";
    
            if (!ClientScript.IsClientScriptBlockRegistered("PopupWindow"))
                ClientScript.RegisterClientScriptBlock(typeof(string), "PopupWindow", Script);
    

    Hope this helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to have a button Print all reports which will print 5 different
i have a list of posts. i want print some words of post content
I want to print applet. There are two ways: Signing applet Add permission java.lang.RuntimePermission
I want to print just the HTTP status code for a web page retrieved
I want to print an attribute value based on its name, take for example
I want to print the ID of the comment (eg. 10151828637085391_33268745 ) from this
I want to print all the prime numbers between two numbers. This is my
I have written a program which analyzes a project's source code and reports various
please help me. I want to print some reports from .NET app. I read
I have written an application in c# and now i want to print its

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.