Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我是 ASP.NET 的新手,我想知道如何在 TableCell 上添加图片。我正在做的是以下内容:
我有两张代表男性和女性的照片。如果“sex” = 1,我想加载男性的图片,如果是“2”,则显示女性图片。
最简单的方法是添加 IMG 标签。
cell5.Text = string.Format("<img src='{0}' />", blaa == "1"? "Male.png" : "Female.png");
string.Format将用第二个参数替换 {0} - 这将根据“blaa”的值选择男性或女性。
string.Format
如果您按原样使用代码 - 您应该将图像放在与 ASPX 文件相同的目录中。