adding image to table cell

Discussion in 'ASP .Net' started by Guest, Oct 28, 2004.

  1. Guest

    Guest Guest

    i am trying to add image to table cell. Here is my code..

    System.Web.UI.WebControls.Image img = new System.Web.UI.WebControls.Image();
    img.ImageUrl="http://localhost/Lhw/Images/i.p.new.gif";
    for(int i=0; i < allRecords.Length; i++)
    {
    TableRow tRow = new TableRow();
    Table2.Rows.Add(tRow);
    TableCell tCell1= new TableCell();
    tCell1.Controls.Add(img);
    tRow.Cells.Add(tCell1);
    }

    The image doesnot appear when the page is run. Is there anything wrong.

    Manny
     
    Guest, Oct 28, 2004
    #1
    1. Advertisements

  2. The code looks good. What is the HTML emitted?

    Also, why are you manually creating a table like this? Might a
    DataGrid, DataList, or Repeater be a better option?

    --

    Scott Mitchell

    http://www.4GuysFromRolla.com

    * When you think ASP.NET, think 4GuysFromRolla.com!
     
    Scott Mitchell [MVP], Oct 28, 2004
    #2
    1. Advertisements

  3. Guest

    Guest Guest

    The image should be in the first <td></td> tags, but it is completely empty.
    <td></td><td></td><td>Caroline Pandolfo</td><td>FW: Employee Reports -
    company Visits - IXOS LHW_EXLK 73
    KB</td><td>2004-03-23T17:19:44.937Z</td><td>4647</td>

    Manny
     
    Guest, Oct 28, 2004
    #3
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.