【发布时间】:2021-06-16 19:50:15
【问题描述】:
我需要在运行时将图像图标添加到特定单元格中的 gridview 数据绑定。
我已经开始编写代码,但我不确定如何完成它,因为使用此代码图像不会在 gridview 中显示...
见下文:
if (e.Row.RowType == DataControlRowType.DataRow)
{
if (e.Row.DataItem != null)
{
ImageButton image = new ImageButton();
image.ImageUrl = "C:/inetpub/wwwroot/img/add-page-red.gif";
e.Row.Cells[2].Controls.Add(image);
}
}
任何帮助将不胜感激...谢谢。
【问题讨论】:
-
为什么要引用驱动器 c?它应该看起来像 image.ImageUrl = "img/add-page-red.gif";
-
@BorisSokolov 感谢您的帮助...
标签: c# asp.net image gridview rowdatabound