Click here to Skip to main content
15,907,001 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i am using ajax file upload control ,when i am saving some file in database then no prablem its working fine ,but when i want save some value from dropdown and textbox value at update event then i am getting error,anybody help me ?

my Code is
C#
protected void AjaxFileUpload1_UploadComplete(object sender, AjaxControlToolkit.AjaxFileUploadEventArgs e)
   {
          string filePath = string.Empty;
           filePath = (Server.MapPath("~/Admin/") + Guid.NewGuid() + System.IO.Path.GetFileName(e.FileName));
           AjaxFileUpload1.SaveAs(filePath);
           string strFile = filePath.Substring(filePath.LastIndexOf("\\"));
           string strFileName = strFile.Remove(0, 1);
           string strFilePath = "~/Admin/" + strFileName;
           SqlCommand cmd = new SqlCommand("Insert into tbl_ImageGallery (Image_Name,Imagepath,Category_Id) values (@Image_Name,@Imagepath,@Category_Id)", con);
           cmd.Parameters.AddWithValue("@Image_Name", strFileName);
           cmd.Parameters.AddWithValue("@Imagepath", strFilePath);
           cmd.Parameters.AddWithValue("@Category_Id",dropcategory.SelectedItem.Value);
           con.Open();
           cmd.ExecuteNonQuery();
           con.Close();
           cmd.Dispose();


   }


dropdownlist controls value is not taking .
Posted
Comments
hsakarp 14-Nov-13 3:23am    
what was the error you are getting?
manvendra patel 14-Nov-13 4:40am    
file does not uplaod when add any control value like cmd.Parameters.AddWithValue("@Category_Id",dropcategory.SelectedItem.Value);
at ajax file update event.
hsakarp 14-Nov-13 4:57am    
as per the error , instead of directly passing the value assign the dropcategory.SelectedItem.Value into a string and attach. This will help
Vishal Pand3y 14-Nov-13 4:00am    
put some breakpoint and see where you are getting error........

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900