Last post Jul 05, 2012 06:43 AM by arcadian_4u
May 14, 2012 10:28 AM|arcadian_4u|LINK
Please help me with binary file upload issue.
I can insert Binary images no problem, but in listview edit mode whenever I update any other filed in the row it deletes the binary data form the colum.
I am using following code in the code behind.
Protected Sub FormView1_ItemUpdating(sender As Object, e As ListViewUpdateEventArgs) Handles ListView1.ItemUpdating
Dim FileUploade1 As FileUpload = ListView1.EditItem.FindControl("FileUploade1")
If FileUploade1.HasFile Then
e.NewValues("SopImg1") = FileUploade1.FileBytes
"I have tried heher e.newvalues("SopImg1")= e.oldvalues("SopImg1"), but it did not work"
I believe you had same issue, Please help.
Thanks in advance
May 15, 2012 05:58 AM|arcadian_4u|LINK
I Had to create button click event to solve this and following code can be use to update the binary picture data only.
Protected Sub img1up(ByVal sender As Object, ByVal e As System.EventArgs)
'Make sure a file has been successfully uploaded
Dim FileUpload1 As FileUpload = ListView1.EditItem.FindControl("FileUpload1")
If FileUpload1.PostedFile Is Nothing OrElse String.IsNullOrEmpty(FileUpload1.PostedFile.FileName) OrElse FileUpload1.PostedFile.InputStream Is Nothing Then
'Make sure we are dealing with a JPG or GIF file
Dim extension As String = Path.GetExtension(FileUpload1.PostedFile.FileName).ToLower()
Dim MIMEType As String = Nothing
Select Case extension
MIMEType = "image/gif"
Case ".jpg", ".jpeg", ".jpe"
MIMEType = "image/jpeg"
MIMEType = "image/png"
'Invalid file type uploaded
'Connect to the database and insert a new record into Products
Using myConnection As New SqlConnection(ConfigurationManager.ConnectionStrings("ConnectionString1").ConnectionString)
Const SQL As String = "UPDATE [table] SET Img1] = @Img1 WHERE [ListID] = @ListID "
Dim myCommand As New SqlCommand(SQL, myConnection)
Dim ListID As Integer = Convert.ToInt32(Request.QueryString("ListID"))
'Load FileUpload's InputStream into Byte array
Dim Img1(FileUpload1.PostedFile.InputStream.Length) As Byte
FileUpload1.PostedFile.InputStream.Read(Img1, 0, Img1.Length)
May 15, 2012 09:50 PM|Decker Dong - MSFT|LINK
I Had to create button click event to solve this and following code can be use to update the binary picture data onl
Welcome to our fourm next time to share your nice solutions as well as chat with us about the technology……
Jul 05, 2012 06:43 AM|arcadian_4u|LINK
Thank you Decker Dong -MSFT,