Click here to Skip to main content
15,881,866 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
C#
#region GetJobs
   protected void GetJobs()
   {
      try
      {
         int index = 0;
         CheckBox cb = new CheckBox();
         Session["ReportConnectionString"] = ",";

         while (index < GridViewSearch.Rows.Count)
         {
            GridViewRow checkedRow = GridViewSearch.Rows[index];
            cb = (CheckBox)checkedRow.FindControl("CheckBoxEdit");

            if (cb.Checked == true)
               Session["ReportConnectionString"] = Session["ReportConnectionString"].ToString() + GridViewSearch.DataKeys[index].Values["AreaId"].ToString() + ",";

            index++;
         }
      }
      catch (Exception ex)
      {
         
      }
   }
#endregion "GetJobs"

#region ButtonSelect_Click
   protected void ButtonSelect_Click(object sender, EventArgs e)
   {
      try
      {
         CheckBox cb = new CheckBox();

         foreach (GridViewRow row in GridViewSearch.Rows)
         {
            cb = (CheckBox)row.FindControl("CheckBoxEdit");
            if (!cb.Checked)
               cb.Checked = true;
            else
               cb.Checked = false;
         }
      }
      catch (Exception ex)
      {

      }
   }
#endregion ButtonSelect_Click

protected void ButtonPrint_Click(object sender, EventArgs e)
{
   try
   {
      GetJobs();
      Session["FromURL"] = "~/Reports/SpaceUtilised.aspx";

      Session["ReportName"] = "Space Utilised";

      Microsoft.Reporting.WebForms.ReportParameter[] RptParameters = new Microsoft.Reporting.WebForms.ReportParameter[5];

      // Create the ConnectionString report parameter
      //string areaId = Session["ReportConnectionString"].ToString();
      //RptParameters[0] = new Microsoft.Reporting.WebForms.ReportParameter("ConnectionString", areaId);
      string areaId = Session["ReportConnectionString"].ToString();
      RptParameters[0] = new Microsoft.Reporting.WebForms.ReportParameter("ConnectionString", areaId);

      // Create the WarehouseId report parameter
      RptParameters[1] = new Microsoft.Reporting.WebForms.ReportParameter("WarehouseId", Session["WarehouseId"].ToString());

      // Create the AreaId report parameter
      RptParameters[2] = new Microsoft.Reporting.WebForms.ReportParameter("AreaId", Session["AreaId"].ToString());

      RptParameters[3] = new Microsoft.Reporting.WebForms.ReportParameter("ServerName", Session["ServerName"].ToString());

      RptParameters[4] = new Microsoft.Reporting.WebForms.ReportParameter("DatabaseName", Session["DatabaseName"].ToString());

      Session["ReportConnectionString"] = null;

      Session["ReportParameters"] = RptParameters;

      Response.Redirect("~/Reports/Report.aspx");
   }
   catch { }
}


additional information copied from non-solution below
Im trying to print out all selected checkbox

My gridview was selecting and I changed it to checkbox now its not working


THIS WAS THE OLD CODE WHICH WAS SELECTING:

C#
protected void Page_Load(object sender, EventArgs e)
{
   if(!Page.IsPostBack)
      Session["AreaId"] = -1;
}

protected void ButtonPrint_Click(object sender, EventArgs e)
{
   try
   {
      Session["FromURL"] = "~/Reports/SpaceUtilised.aspx";

      Session["ReportName"] = "Space Utilised";

      Microsoft.Reporting.WebForms.ReportParameter[] RptParameters = new Microsoft.Reporting.WebForms.ReportParameter[5];

      // Create the ConnectionString report parameter
      string strReportConnectionString = Session["ReportConnectionString"].ToString();
      RptParameters[0] = new Microsoft.Reporting.WebForms.ReportParameter("ConnectionString", strReportConnectionString);

      // Create the WarehouseId report parameter
      RptParameters[1] = new Microsoft.Reporting.WebForms.ReportParameter("WarehouseId", Session["WarehouseId"].ToString());

      // Create the AreaId report parameter
      RptParameters[2] = new Microsoft.Reporting.WebForms.ReportParameter("AreaId", Session["AreaId"].ToString());

      RptParameters[3] = new Microsoft.Reporting.WebForms.ReportParameter("ServerName", Session["ServerName"].ToString());

      RptParameters[4] = new Microsoft.Reporting.WebForms.ReportParameter("DatabaseName", Session["DatabaseName"].ToString());

      Session["ReportParameters"] = RptParameters;

      Response.Redirect("~/Reports/Report.aspx");
   }
   catch { }
}

protected void CheckBoxAll_OnCheckedChanged(object sender, EventArgs e)
{
   if (CheckBoxAll.Checked)
   {
      Session["AreaId"] = -1;
      AreaSearch1.Visible = false;
   }
   else
      AreaSearch1.Visible = true;
}


Then I had to change it to checkbox because I want to be able to select multiple rows
Posted
Updated 24-Oct-14 2:25am
v3
Comments
Sinisa Hajnal 24-Oct-14 6:45am    
And your question / problem is?
Laiju k 24-Oct-14 7:22am    
what are trying to do?

1 solution

Im trying to print out all selected checkbox

My gridview was selecting and I changed it to checkbox now its not working


THIS WAS THE OLD CODE WHICH WAS SELECTING:

C#
protected void Page_Load(object sender, EventArgs e)
    {
        if(!Page.IsPostBack)
            Session["AreaId"] = -1;
    }

    protected void ButtonPrint_Click(object sender, EventArgs e)
    {
        try
        {
            Session["FromURL"] = "~/Reports/SpaceUtilised.aspx";

            Session["ReportName"] = "Space Utilised";

            Microsoft.Reporting.WebForms.ReportParameter[] RptParameters = new Microsoft.Reporting.WebForms.ReportParameter[5];

            // Create the ConnectionString report parameter
            string strReportConnectionString = Session["ReportConnectionString"].ToString();
            RptParameters[0] = new Microsoft.Reporting.WebForms.ReportParameter("ConnectionString", strReportConnectionString);

            // Create the WarehouseId report parameter
            RptParameters[1] = new Microsoft.Reporting.WebForms.ReportParameter("WarehouseId", Session["WarehouseId"].ToString());

            // Create the AreaId report parameter
            RptParameters[2] = new Microsoft.Reporting.WebForms.ReportParameter("AreaId", Session["AreaId"].ToString());

            RptParameters[3] = new Microsoft.Reporting.WebForms.ReportParameter("ServerName", Session["ServerName"].ToString());

            RptParameters[4] = new Microsoft.Reporting.WebForms.ReportParameter("DatabaseName", Session["DatabaseName"].ToString());

            Session["ReportParameters"] = RptParameters;

            Response.Redirect("~/Reports/Report.aspx");
        }
        catch { }
    }

    protected void CheckBoxAll_OnCheckedChanged(object sender, EventArgs e)
    {
        if (CheckBoxAll.Checked)
        {
            Session["AreaId"] = -1;
            AreaSearch1.Visible = false;
        }
        else
            AreaSearch1.Visible = true;
    }
}


Then I had to change it to checkbox because I want to be able to select multiple rows
 
Share this answer
 
Comments
Nelek 24-Oct-14 8:16am    
If you need to add or change content to your question or a previous solution, please use the "improve question / solution" instead of writing a new messages. It will keep readability and help other users with similar problems to find it faster.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900