ASP.NET Add Picture to TableCell

4.1k views Asked by At

I'm kind of new to ASP.NET and I would like to know how it's possible to add a Picture on a TableCell. What I am doing is the following :

I have two pictures that Represent Male & Female. I want to load a picture of a male if "sex" = 1 , if it's "2", display the female picture.

1

There are 1 answers

1
Yuriy Galanter On BEST ANSWER

Easiest way is to just add IMG tag.

cell5.Text = string.Format("<img src='{0}' />", blaa == "1"? "Male.png" : "Female.png");

string.Format will substitute {0} with the second parameter - which will select either male or female based on value of "blaa".

If you use the code as is - you should place the images into the same directory as your ASPX file.