title: Gridview - Pop-up Image in another box when clicked on
body: <p>I am using Visual Studio 2017 with vb.net.  I have a gridview in which one column is an image.  I would like to click on the image and have the image pop-up in another box displaying the picture larger with a close button.  I haven't programmed in forever, I'm relearning vb.net, and, of course, my boss needed this yesterday.  So, just showing the image part of the grid, my code is:</p>
  <pre><code>&lt;asp:TemplateField HeaderText=&quot;Image&quot; ItemStyle-HorizontalAlign=&quot;Center&quot; ItemStyle-Width=&quot;50px&quot;&gt;
      &lt;ItemTemplate&gt;
          &lt;asp:Imagebutton ID=&quot;Img&quot; runat=&quot;server&quot; ImageUrl='&lt;%# Eval(&quot;ImageBase64&quot;, &quot;{0}&quot;) %&gt;' ControlStyle-Width=&quot;100&quot; ControlStyle-Height = &quot;100&quot; /&gt;
      &lt;/ItemTemplate&gt;
  &lt;/asp:TemplateField&gt;
  </code></pre>
  <p>So, the image shows in the grid:</p>
  <pre><code>Imports System.Configuration
  Imports System.Data.SqlClient
  Imports System.Drawing
  Imports System.IO
  
  Public Class _default
      Inherits System.Web.UI.Page
  
      Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
  
          Dim connectionStr As String = ConfigurationManager.ConnectionStrings(&quot;ictsqlConnection&quot;).ConnectionString
  
          Using con As SqlConnection = New SqlConnection(connectionStr)
              'open
              con.Open()
  
              Using cmd As SqlCommand = New SqlCommand(&quot;SELECT SurplusId, Department, Category, Item, VehicleMileage, SerialNo, AgeValueinYrs, AgeValueinMons, Visible, Image FROM Surplus&quot;, con)
                  Using da As SqlDataAdapter = New SqlDataAdapter(cmd)
  
                      Dim dt As DataTable = New DataTable()
  
                     'fill DataTable with data from database
                      da.Fill(dt)
  
                     'add column that will store the image as a base64 string
                      dt.Columns.Add(&quot;ImageBase64&quot;, GetType(System.String))
  
                      For i As Integer = 0 To dt.Rows.Count - 1
                          'convert image Byte() from database to base64 string and store in a new column in the DataTable
                          dt(i)(&quot;ImageBase64&quot;) = &quot;data:image/jpg;base64,&quot; &amp; Convert.ToBase64String(CType(dt(i)(&quot;Image&quot;), Byte()))
  
                      Next
  
                      'remove column that contains Byte() from DataTable
                      dt.Columns.Remove(&quot;Image&quot;)
  
                      GridView1.DataSource = dt
                      GridView1.DataBind()
                  End Using
              End Using
          End Using
      End Sub
  End Class
  </code></pre>
  <p>I've searched for how to display picture in pop-up and nothing is working. The ImageButton does allow me to click on the picture (lol), but I can't figure out what code to put behind it so the image comes up in a pop-up.  I appreciate any help you can give me.  Thank you in advance.</p>