我正在动态创建带有图像的HyperLink,并将其输入到数据集的每个单元格中。 好吧,由于某种原因,图像没有出现在任何细胞中,链接在那里,但图像不是,我不明白为什么。 当我逐步完成代码时,ImageUrl是正确的,当我复制路径并粘贴到资源管理器中时,图像会显示,但它不会显示在单元格中。
代码是......
for (cellCtr = 1; cellCtr <= 3; cellCtr++)
{
HyperLink link = new HyperLink();
// Create a new cell and add it to the row.
TableCell tCell = new TableCell();
/* If the rowcounter is equal to the record numbers
* then it has to break because if not it will throw an error
* saying that there is no row at ending position */
if (rowCtr == rN)
break;
string subjectid = myDs.Tables[0].Rows[rowCtr]["SubjectID"].ToString();
string iconUrl = myDs.Tables[0].Rows[rowCtr]["IconUrl"].ToString();
link.ID = subjectid;
link.ImageUrl = iconUrl;
link.NavigateUrl = "~/WebForm2.aspx";
tCell.Controls.Add(link);
tRow.Cells.Add(tCell);
rowCtr++;
/* If the cellcount is 3 then it needs to break, if not then
* you'll miss every 4rth record, don't know why. But this works */
if (cellCtr == 3)
{
rowCtr = rowCtr - 1;
break;
}
}
我不知道为什么图像不会出现......
由于