protected void btnSubmit_Click(object sender, EventArgs e) { //if (DDL_Category1.SelectedItem.Text == "----Select----") //{ // DDL_Category1.SelectedItem.Value = "0"; //} //if (DDL_Category2.SelectedItem.Text == "----Select----") //{ // DDL_Category2.SelectedItem.Value = "0"; //} //if (DDL_Category3.SelectedItem.Text == "----Select----") //{ // DDL_Category3.SelectedItem.Value = "0"; //} //if (DDL_Category4.SelectedItem.Text == "----Select----") //{ // DDL_Category4.SelectedItem.Value = "0"; //} //if (DDL_Brand.SelectedItem.Text == "----Select----") //{ // DDL_Brand.SelectedItem.Value = "0"; //} if (HiddenField_Edit.Value != "") { if (HiddenField_Delete.Value != "") { AL.productProperties.productID = Convert.ToInt32(HiddenField_Edit.Value); AL.ProductDelete(); GridView1.DataBind(); HiddenField_Edit.Value = ""; HiddenField_Delete.Value = ""; Button1.Text = "Save"; } else { AL.productProperties.productID = Convert.ToInt32(HiddenField_Edit.Value); string filename1 = Path.GetFileName(fileuploadimages.PostedFile.FileName); fileuploadimages.SaveAs(Server.MapPath("Images/" + fileuploadimages.FileName)); AL.productProperties.productName = TXT_Product_Name.Text.Trim().ToString(); AL.productProperties.filename = "Images/" + filename1; AL.productProperties.categoryID = Convert.ToInt32(DDL_Category1.SelectedItem.Value); AL.productProperties.subCategory1ID = Convert.ToInt32(DDL_Category2.SelectedItem.Value); AL.productProperties.subCategory2ID = Convert.ToInt32(DDL_Category3.SelectedItem.Value); AL.productProperties.subCategory3ID = Convert.ToInt32(DDL_Category4.SelectedItem.Value); AL.productProperties.brandID = Convert.ToInt32(DDL_Brand.SelectedItem.Value); AL.productProperties.price = Txt_Price.Text.Trim().ToString(); AL.productProperties.description = TXT_Description.InnerText.Trim().ToString(); AL.productProperties.quantity = Txt_Quantity.Text.Trim().ToString(); AL.ProductEdit(); GridView1.DataBind(); HiddenField_Edit.Value = ""; Button1.Text = "Save"; } } else { string filename = Path.GetFileName(fileuploadimages.PostedFile.FileName); fileuploadimages.SaveAs(Server.MapPath("Images/" + fileuploadimages.FileName)); AL.productProperties.productName = TXT_Product_Name.Text.Trim().ToString(); AL.productProperties.filename = "Images/" + filename; AL.productProperties.categoryID = Convert.ToInt32(DDL_Category1.SelectedItem.Value); AL.productProperties.subCategory1ID = Convert.ToInt32(DDL_Category2.SelectedItem.Value); AL.productProperties.subCategory2ID = Convert.ToInt32(DDL_Category3.SelectedItem.Value); AL.productProperties.subCategory3ID = Convert.ToInt32(DDL_Category4.SelectedItem.Value); AL.productProperties.brandID = Convert.ToInt32(DDL_Brand.SelectedItem.Value); AL.productProperties.price = Txt_Price.Text.Trim().ToString(); AL.productProperties.description = TXT_Description.InnerText.Trim().ToString(); AL.productProperties.quantity = Txt_Quantity.Text.Trim().ToString(); AL.ProductInsert(); } Response.Redirect("Manage_Products.aspx"); //http://www.aspdotnet-suresh.com/2011/03/how-to-save-images-into-folder-and.html }