title: C#.net how to add an image into a table cell dynamically by code
body: <p>I am trying to add an image into a table that I'm making dynamically by code behind.
  However the image is not added  to the cell.
  All the other codes I'm finding are talking about an htmltable which is not the same as table();</p>
  
  <pre><code>public partial class Children_nihul_1 : System.Web.UI.Page
  {
      protected string mychildrenlist;
  
      protected void Page_Init(object sender, EventArgs e)
      {
          var cases = new List&lt;string&gt;();
          System.Web.UI.WebControls.Image myGamepic1 = new System.Web.UI.WebControls.Image();
         // var myGamepic1 = new Image();
          myGamepic1.ImageUrl = "~/img/inner-page/Game1.png";
          myGamepic1.Height = 30;
  </code></pre>
  
  <blockquote>
    <p>//this part is only a call for data from database- not relavent to the
    qustion./</p>
  </blockquote>
  
  <pre><code>        DataSet ds = new DataSet();
          string x = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + Server.MapPath("./App_Data/DatabaseGames.accdb") + ";";
          string y = "select * from Students";
  
          mySql myq = new mySql();
          ds = myq.sqlRet(x, y);
          rowlist = ds.Tables[0].Rows.Count;
  
          for (int i = 0; i &lt; rowlist; ++i)
          {
              cases.Add(ds.Tables[0].Rows[i][1].ToString()); 
          }
  </code></pre>
  
  <blockquote>
    <p>//my table creation</p>
  </blockquote>
  
  <pre><code>        Table table = new Table();
          table.BorderStyle = BorderStyle.None;
  
          //Add Header Row
          TableRow row = new TableRow();
          TableHeaderCell headerCell = new TableHeaderCell();
          headerCell.Text = "aaa";
  
          row.Controls.Add(headerCell);
          headerCell = new TableHeaderCell();
          headerCell.Text = "ccc";
          row.Controls.Add(headerCell);
  
          table.Controls.Add(row);
  
          for (int i = 0; i &lt; rowlist; ++i)
          {
              //Add DataRow
              row = new TableRow();
              TableCell cell = new TableCell();
              cell.Text = cases[i];
              row.Controls.Add(cell);
  
              cell = new TableCell();
              cell.Controls.Add(myGamepic1);
  
              row.Controls.Add(cell);
  
              table.Controls.Add(row);
          }
  
          Panel1.Controls.Add(table);
          Panel1.Controls.Add(myGamepic1);
      }
  
  }
  </code></pre>