hello.. i am making website on "online electronics products"
in asp.net in the product table i have
product id
product name
product price
product imageurl
i have completed the user part that is ... add items to cart, edit cart,shopping etc...
now i want to do the admin part to add new items in the product table and edit existing..
i can add/edit the product code, price and name... bt how to add image using FileUpload? (the field imageurl is string)
and also i want to save that image in my project's (items) folder...
Thanx...!
Loading

Dipa AhujaPosted Oct 31, 2009, 12:40 PM
here file upload button is simple bt in my code it is inside the details view...!
so in the code how to write the controlId Property of detailsView 's btnUpload :
Dipa AhujaPosted Oct 27, 2009, 12:05 PM
hi would u plz see y the fileupload not working when i use ajax updatepanel...
http://www.mediafire.com/file/tlzn5jzgmjw/admin.rar
Dipa AhujaPosted Oct 26, 2009, 1:52 PM
i 4got to write this:
bt 1 problem when i take Ajax's updatepanel.. in my updateproduct.aspx, its not uploading the image.. y its happening so?
Dipa AhujaPosted Oct 26, 2009, 1:30 PM
and those images i want to store is from root : "products/items"
Dipa AhujaPosted Oct 26, 2009, 1:27 PM
To Kirtan ..
hi...i tried tht way as u have suggested..
bt its working bt not fully..
in updateproducts.aspx i have
1 datalist control and 1 detailsview control....
DETEAILSVIEW & SQLDATASOURCE
DATA LIST SQLDATA SOURCE:
and at the top:
so by ur code i wrote:
it stores image in the folder, bt not the imageurl in the database...!
where is the problem?
thanx!
Mahesh ChandPosted Oct 26, 2009, 11:56 AM
Kirtan PatelPosted Oct 26, 2009, 11:50 AM
Here is your Solution
take one FileUpload Control and One Button Control and Code Like Below
protected void btnUpload_Click(object sender, EventArgs e)
{
if (FileUpload1.HasFile == true)
{
//Get Just FileName not Full path of File
string FileName = FileUpload1.FileName;
//Get Actual Path of Images Folder on Server
string FolderPathToSave = Server.MapPath("images");
//Save Image in Images Folder
FileUpload1.SaveAs(FolderPathToSave+@"\"+FileName);
string PathToStoreInDatabase = @"~\images\" + FileName;
// Insert PathToStoreDatabase in Database to Retrive Image Path Again When you need From Database
//Like If you want to Show Uploaded Image in Picture Control Then Code below
Image1.ImageUrl = PathToStoreInDatabase;
}
}
All the Best :)