12
Answers

session variable and aspx problem

vaquas khan

vaquas khan

14y
11.9k
1
my Customer_TotalSales.aspx page have 4 control such as.....DropdownList1,DropdownList2,Datepicker1,Datepicker2 and 1 button
button_click event code  of Customer_TotalSales.aspx are below...

protected void Button1_Click1(object sender, EventArgs e)
    {        
 Session["@FromCustomerName"] = DropDownList1.SelectedValue;
      Session["@ToCustomerName"] = DropDownList2.SelectedValue;
      Session["@FromDate"] = DatePicker1.SelectedDate;
      Session["@ToDate"] = DatePicker2.SelectedDate;
      Response.Redirect("SessionVariable.aspx");
}
Another aspx SessionVariable.aspx  its have 4 lable control which hold the session variable value and pass these value to crystal report Viewer control...
public partial class SessionVariable : System.Web.UI.Page
{     
    protected void Page_Load(object sender, EventArgs e)
    {
        LabFromCustomer.Text = Session["@FromCustomerName"].ToString();
        LabToCustomer.Text = Session["@ToCustomerName"].ToString();
        LabFromDate.Text = Session["@FromDate"].ToString();
        LabToDate.Text = Session["@ToDate"].ToString();
        CrystalReportViewer1.Visible = false;
        CrystalReportViewer1.Visible = true;
        CrystalReportSource1.Report.FileName = Server.MapPath("Reports/Customer_totalsalesTest.rpt");
        ParameterDiscreteValue objDiscreteValue;
        ParameterField objParameterField;
        //Set value for first parameter.....
        objDiscreteValue = new ParameterDiscreteValue();
        objDiscreteValue.Value = LabFromDate.Text;
        objParameterField = CrystalReportViewer1.ParameterFieldInfo["@FromDate"];
        objParameterField.CurrentValues.Add(objDiscreteValue);
        CrystalReportViewer1.ParameterFieldInfo.Add(objParameterField);
        objParameterField = CrystalReportViewer1.ParameterFieldInfo["@ToDate"];
        //Set value for second parameter......
        objDiscreteValue = new ParameterDiscreteValue();
        objDiscreteValue.Value = LabToDate.Text;
        objParameterField.CurrentValues.Add(objDiscreteValue);
        CrystalReportViewer1.ParameterFieldInfo.Add(objParameterField);
        //Set value for Third parameter......
        objDiscreteValue = new ParameterDiscreteValue();
        objDiscreteValue.Value = LabFromCustomer.Text;
        objParameterField = CrystalReportViewer1.ParameterFieldInfo["@FromCustomerName"];
        objParameterField.CurrentValues.Add(objDiscreteValue);
        CrystalReportViewer1.ParameterFieldInfo.Add(objParameterField);
        objDiscreteValue = new ParameterDiscreteValue();
        objParameterField = CrystalReportViewer1.ParameterFieldInfo["@ToCustomerName"];
        objDiscreteValue.Value = LabToCustomer.Text;
        objParameterField.CurrentValues.Add(objDiscreteValue);
        CrystalReportViewer1.ParameterFieldInfo.Add(objParameterField);
        CrystalReportViewer1.ReportSourceID = "CrystalReportSource1";

    }
}

when i Execute First page then asking for 4 value DropdownList1,DropdownList2,Datepicker1,Datepicker2 ..i choose these value when i click button then SessionVariable.aspx execute and show the crystal report everything working nice till now ...
when i want change the value of parameter then i need to close the page and Re-Execute the page ........

 please  help me ...how can i Changed the parameter value to change theese value   DropdownList1,DropdownList2,Datepicker1,Datepicker2 in one time execution.....whats i edit in my code for that.......


Answers (12)