Click here to Skip to main content
11,578,241 members (65,553 online)

Dev.Vikas.S asked:

Open original thread
Dear friends,

Here, i've used public static string A; variable in my application.
Suppose, user1 hav A="1" and now user2 come to this form and he has A=2.
So, in this case original value of A for user1(which is A=1) replaced with user2(which is now A=2), But i want to keep both of the value saprately for both the users..

Note :
1) i used public string A; but during postback it lost its value.

i dont want to use session variable for this.

sample coding part for reference-->

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Data.SqlTypes;
using System.Data.SqlClient;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using CrystalDecisions.Web;
using CrystalDecisions.Shared;
using CrystalDecisions.CrystalReports.Engine;
 
public partial class PO_REG : System.Web.UI.Page
{
   
    public static string A; 
    public static string _print; 
    public void Page_Init(object sender, EventArgs e)
    {
        if (_print == "P")
        {
            ViewReport();
        }
    }
       #endregion
 
    protected void btnShowReport_Click(object sender, ImageClickEventArgs e)
    {
        _print = "P";
        A = Rdbtn.SelectedValue;        
        ViewReport()
    }
 
    private void ViewReport()
    {
        ReportDocument crystalReport = new ReportDocument();
        if (A == "1")
        {
            crystalReport.Load(Server.MapPath("sample1.rpt"));
        }
        else if (A == "2")
        {
            crystalReport.Load(Server.MapPath("sample2.rpt"));
        }
    }


any help would be highly appriciated....
thank you.
Tags: C#4.0, ASP.NET

Preview



When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the The Code Project Open License (CPOL).



Advertise | Privacy | Mobile
Web04 | 2.8.150603.1 | Last Updated 26 Mar 2009
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100