Display Binary Image in ASP.Net GridView control using C# and VB.Net

Last Reply 4 months ago By dharmendr

Posted 4 months ago

I have a Gridview control and along with the name, surname and code of the employee I would like to place an image of the employee also. In the database I am using SQL server and the image is displayed as data type 'image'. Is it possible to place the image inside the gridview control.

This is my code to populate the Gridview from back end:

         Try
            Using conn As New SqlConnection(ConfigurationManager.ConnectionStrings("##").ConnectionString)

                Using cmd As New SqlCommand("SELECT Code, (FirstName + ' ' + LastName) AS [Employee Name] , EmployeeID ,DateOfMedical , Certificate FROM  MedicalCertificate Order By DateOfMedical ASC", conn)

                    Dim sda As New SqlDataAdapter(cmd)
                    Dim dt As New DataTable()
                    sda.Fill(dt)

                    conn.Open()

                    GridView1.DataSource = dt
                    GridView1.DataBind()

                    conn.Close()

                End Using

            End Using

        Catch ex As Exception

        End Try