View Single Post
Old July 5th, 2007, 05:28 AM
vijiljones vijiljones is offline
Registered User
Join Date: Oct 2006
Location: , , .
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default C# Global variable issues.

Hi all,

I wrote code like this

public partial class frmTaskView : System.Web.UI.Page
    private int intVar;
    protected void Page_Load(object sender, EventArgs e)
        if (!IsPostBack)
          // Call the dataBase sp and assign the variable intVar
          intVar = "10"; // Set through the Databace call
    protected void btnSearch_Click(object sender, EventArgs e)
       // do search based on the Variable intVar

        when I click the Search button I am always getting value 0.
If I remove the IsPostBack condition I am getting actual value.This is increasing the Database call.

How I persist the value without the Database call. Please help me.