Click here to Skip to main content
15,891,473 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
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

VB
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()

      'picCompanyLogo.Image = Convert.ToByte(gdCompany.CurrentRow.Cells(15).Value.ToString())
     
      txtCompanyName.Focus()
  End Sub
Posted
Updated 3-Nov-12 4:37am
v3

1 solution

now it is ok with this solution.

VB
Try
           'Get image data from gridview column.
           Dim imageData As Byte() = DirectCast(gdCompany.CurrentRow.Cells(15).Value, Byte())
           'Initialize image variable
           Dim newImage As Image
           'Read image data into a memory stream
           Using ms As New MemoryStream(imageData, 0, imageData.Length)
               ms.Write(imageData, 0, imageData.Length)
               'Set image variable value using memory stream.
               newImage = Image.FromStream(ms, True)
           End Using
           'set picture
           picCompanyLogo.Image = newImage
       Catch ex As Exception
           MessageBox.Show(ex.ToString())
       End Try
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900