|
I'm using Stored Procedure,3 tier and VB.net.
Now, i click the gridview and then want to show the data in textboxes and pictureBox to update the informations.
The problem is that , how can i retrieve photo to picture box???
Here is my code
Private Sub gdCompany_CellClick(ByVal sender As System.Object, ByVal e As Telerik.WinControls.UI.GridViewCellEventArgs) Handles gdCompany.CellClick
btnSave.Text = "ျပင္ရန္"
txtCompanyName.Text = gdCompany.CurrentRow.Cells(1).Value.ToString()
txtDescription.Text = gdCompany.CurrentRow.Cells(2).Value.ToString()
txtPhoneNo.Text = gdCompany.CurrentRow.Cells(3).Value.ToString()
txtFaxNo.Text = gdCompany.CurrentRow.Cells(4).Value.ToString()
txtEmail.Text = gdCompany.CurrentRow.Cells(5).Value.ToString()
txtWebsite.Text = gdCompany.CurrentRow.Cells(6).Value.ToString()
ddlBankName.SelectedValue = Convert.ToInt32(gdCompany.CurrentRow.Cells(7).Value.ToString())
ddlBankBranch.SelectedValue = Convert.ToInt32(gdCompany.CurrentRow.Cells(8).Value.ToString())
txtBankAccountNo.Text = gdCompany.CurrentRow.Cells(9).Value.ToString()
txtAddress.Text = gdCompany.CurrentRow.Cells(10).Value.ToString()
txtCompanyName.Focus()
End Sub
|
|
|
|
|
I'd recommend creating a "new application" to try implement this technique; that way you won't be bothered with code that has little to do with this particular problem.
You already have the bytes; you can put those in a memorystream[^] and load your image from that stream[^].
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|
hy
This function converts byte array to image:
Public Shared Function ByteArrayToImage(ByVal ByteArr() As Byte) As Object
Dim ImageStream As System.IO.MemoryStream
Try
If ByteArr.GetUpperBound(0) > 0 Then
ImageStream = New System.IO.MemoryStream(ByteArr)
Return Image.FromStream(ImageStream)
Else
Return Nothing
End If
Catch ex As Exception
Return Nothing
End Try
End Function
and this convert back:
Public Shared Function ImageToByteArray(ByVal NewImage As Image) As Object
Dim ImageStream As System.IO.MemoryStream
Dim ByteArr() As Byte
Try
ReDim ByteArr(0)
If NewImage IsNot Nothing Then
ImageStream = New System.IO.MemoryStream
NewImage.Save(ImageStream, Imaging.ImageFormat.Jpeg)
ReDim ByteArr(CInt(ImageStream.Length - 1))
ImageStream.Position = 0
ImageStream.Read(ByteArr, 0, CInt(ImageStream.Length))
End If
Return ByteArr
Catch ex As Exception
Return Nothing
End Try
End Function
+You need DBNull check when the column allow nulls.
|
|
|
|