title: Load image to Gridview
body: <p>I have been trying to figure this out all day.  I am trying to load a GridView with data from SQL in 3 columns and then dynamically add an image to a 4th column.  The data from SQL loads fine but I can not get the images to load no matter what I do.  Here is my code:</p>
  
  <pre><code>SqlCommand cmd1 = new SqlCommand("StoredProc", myConnection1);
  cmd1.CommandType = CommandType.StoredProcedure;
  SqlDataReader reader = cmd1.ExecuteReader();
  while (reader.Read())
  {
       if (reader["ServiceStatus"].ToString().ToLower() == "stopped")
       {
            ImageField status = new ImageField();
            status.HeaderText = "Status";
            status.Visible = true;
            GridView1.Columns.Add(status);
            status.DataAlternateTextFormatString = @"~/Images/Image.gif";
       }
  
       GridView1.DataSource = reader;
       GridView1.DataBind();
  }
  </code></pre>
  
  <p>I have tried creating a data table and populating that and it still will not work.  I know there has to be an easy way to do this.  What am I missing?</p>
  
  <p>EDIT:</p>
  
  <p>I am using a TemplateField now and I am getting a default image to show up:</p>
  
  <pre><code>&lt;asp:TemplateField HeaderText="Status"&gt;
       &lt;ItemTemplate&gt;
            &lt;asp:Image ID="Image1" runat="server" ImageUrl="~/Images/greydot.jpg"/&gt;
       &lt;/ItemTemplate&gt;
  &lt;/asp:TemplateField&gt;
  </code></pre>
  
  <p>So how should I reference this ImageURL in my code behind in order to change that image?  The images are store in the solution not in SQL.</p>