Click here to Skip to main content
11,411,494 members (61,816 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: Windows Gridview VB.NET .NET4 , +
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()
 
        'picCompanyLogo.Image = Convert.ToByte(gdCompany.CurrentRow.Cells(15).Value.ToString())
            
        txtCompanyName.Focus()
    End Sub
Posted 1-Nov-12 19:21pm
Edited 3-Nov-12 5:37am
v3

1 solution

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

Solution 1

now it is ok with this solution.

 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
  Permalink  

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

  Print Answers RSS
0 OriginalGriff 223
1 Sergey Alexandrovich Kryukov 195
2 Sascha Lefévre 155
3 ProgramFOX 90
4 Dave Kreskowiak 90
0 Sergey Alexandrovich Kryukov 8,920
1 OriginalGriff 7,128
2 Maciej Los 3,440
3 Abhinav S 3,248
4 Peter Leow 3,059


Advertise | Privacy | Mobile
Web03 | 2.8.150414.5 | 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