Hi,
I created listview with image saved in Database,
Now I want to edit it,
I added File Upload to my listView in Edit Part
Now I want to save new image in Database (Update)
I Added this code to update Button
protected void UpdateButton_Click(object sender, EventArgs e) { try { FileUpload fUpload = (FileUpload)ListView1.InsertItem.FindControl("FileUpload1"); TextBox txtName = (TextBox)ListView1.InsertItem.FindControl("TextBox3"); TextBox txtPrice = (TextBox)ListView1.InsertItem.FindControl("TextBox2"); if (fUpload.HasFile && fUpload.PostedFile.ContentLength > 0) { string fileName = fUpload.FileName; byte[] fileByte = fUpload.FileBytes; Binary imgBinary = new Binary(fileByte); TestDataContext db = new TestDataContext(); Table1 t = new Table1() { Name = txtName.Text, Price = int.Parse(txtPrice.Text), image = imgBinary, }; db.Table1.InsertOnSubmit(t); db.SubmitChanges(); ListView1.DataBind(); } } catch (Exception ex) { } }
What is problem here
Plz Help me THANKS