Click here to Skip to main content
11,791,059 members (55,707 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: Windows Gridview VB.NET .NET4 , +
I'm using Stored Procedure,3 tier and
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()
      'picCompanyLogo.Image = Convert.ToByte(gdCompany.CurrentRow.Cells(15).Value.ToString())
  End Sub
Posted 1-Nov-12 18:21pm
Edited 3-Nov-12 4:37am

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

now it is ok with this solution.

           '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
       End Try

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

  Print Answers RSS
0 OriginalGriff 1,329
1 Maciej Los 835
2 ppolymorphe 780
3 KrunalRohit 686
4 CPallini 661

Advertise | Privacy | Mobile
Web03 | 2.8.1509028.1 | Last Updated 3 Nov 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100