SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["Safa"].ConnectionString); string branchid = ""; protected void Page_Load(object sender, EventArgs e) { branchid= Session["branchid"].ToString(); if (IsPostBack == false) { Image1.ImageUrl = "left1.ashx?BranchId=" + branchid; Image2.ImageUrl = "left1old.ashx?BranchId=" + branchid; } protected void Button1_Click(object sender, EventArgs e) {// update code SqlCommand cmdupdate = new SqlCommand("left1update", con); cmdupdate.CommandType = CommandType.StoredProcedure; con.Open(); cmdupdate.Parameters.AddWithValue("@BranchId", branchid); if ( FileUpload1.HasFile) { FileInfo left1info = new FileInfo( FileUpload1.PostedFile.FileName.Trim()); byte[] left1content = new byte[left1info.Length]; FileStream left1stream = left1info.OpenRead(); left1stream.Read(left1content, 0, left1content.Length); left1stream.Close(); cmdupdate.Parameters.AddWithValue("@imgleft1",left1content); } cmdupdate.Parameters.AddWithValue("@notel1",txtnotes.Text); if(cmdupdate.ExecuteNonQuery()!=0) { Functions.ShowAlertMessage("Updated....."); txtnotes.Text = ""; System.Threading.Thread.Sleep(2000); Image1.ImageUrl = "left1.ashx?BranchId=" + Session["branchid"].ToString(); Image2.ImageUrl = "left1old.ashx?BranchId=" + Session["branchid"].ToString(); }