Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Anil Sharma
  Where is Anil Sharma?
 ludhiana
 India
 Anil Sharma
 To: Santosh Mishra
  Where is Santosh Mishra?
 Lucknow
 India
 Santosh Mishra
 Tags
Subject: RE: .Net Variable problem
Thread ID: 416185 Message ID: 416278 # Views: 38 # Ratings: 1
Version: Unknown Category: C#.NET
Date: Thursday, December 25, 2014 7:25:28 PM         
   


> At my learning stage I have a prob.
>
> I declared a variable "branch" in Page_Load event
> but when I tried to use it in Button2_Click event, it is giving error.
>
> Please help.....
>
> It would good for me, if help will be in my level
>
>
>
> protected void Page_Load(object sender, EventArgs e)
> {
> string branch= null;
> if (Session["sfld1"].ToString() == "ITOFF")
> {
> branch = "IT";
> Label1.Text = "INDIRA NAGAR BRANCH";
> }
> }
>
> protected void Button2_Click(object sender, EventArgs e)
> {
> SqlConnection con = new SqlConnection("Server=SDCHO\\SQLEXPRESS;Database=LoginPage;Trusted_Connection=true");
> con.Open();
> SqlCommand cmd = new SqlCommand();
>
> cmd.CommandText = "Update LeaveDataTable SET BRANCH_OFF= @branch_off1 where Lsr=@Lsr1 and Lbr=@Lbr1";
>
> cmd.Parameters.AddWithValue("@branch_off1", RadioButtonList2.SelectedItem.Value.ToString());
> cmd.Parameters.AddWithValue("@Lsr1", Convert.ToInt32(TextBox1.Text));
>
> cmd.Parameters.AddWithValue("@Lbr1", branch);
>
> cmd.Connection = con;
> int result = cmd.ExecuteNonQuery();
>
>
> GridView1.DataBind();
> con.Close();
> }


Alternative to Boris and Zia you can use session or cookie variable too!

Anil


Accounting Software

Web Development

Accounting, Inventory, Hotel Management, Restaurant Kot Billing, MLM, Excise Accounting and much much more!.
My Blog

ENTIRE THREAD

.Net Variable problem Posted by Santosh Mishra @ 12/23/2014 8:22:55 AM
RE: .Net Variable problem Posted by Borislav Borissov @ 12/23/2014 8:36:49 AM
RE: .Net Variable problem Posted by Zia Mughal @ 12/23/2014 8:51:12 AM
RE: .Net Variable problem Posted by Anil Sharma @ 12/25/2014 7:25:28 PM