我是新手,很难添加链接,在动态添加的表格中显示为 img。
string search = Search.Text;
IMyData members = new MyData();
DataTable dt = new DataTable();
dt = members.Search(search);
Table t = new Table();
t.ID = "tblTable";
TableRow row = null;
for (int i = 0; i < dt.Rows.Count; i++)
{
HyperLink link = new HyperLink();
row = new TableRow();
for (int j = 0; j < dt.Columns.Count; j++)
{
TableCell cell = new TableCell();
if (j == dt.Columns.Count - 1) //This last field may hava a number
{
if (Convert.ToInt32(dt.Rows[i][j].ToString()) > 0)
{
link.ID = "link" + i + "_" + j;
link.NavigateUrl = "members.aspx?showLease=" + dt.Rows[i][j].ToString();
link.ImageUrl = "img/document.png";
Page.Controls.Add(link); // How to put this in a cell, not on page
}
else
{
cell.Text = dt.Rows[i][j].ToString();
}
}
row.Cells.Add(cell);
}
t.Rows.Add(row);
}
pnlTable.Controls.Add(t);
如何将超链接放到单元格而不是页面?
谢谢