我试图在page_load填充表,但没有显示,我知道我有来自数据库的结果。下面是我的代码:
p>
public void showRecommendations(string data)
{
Recommendations recommendList = new Recommendations();
List<string> similarUsers = new List<string>();
List<RecommendedWebsites> recommendationList = new List<RecommendedWebsites>();
recommendationList = recommendList.getRecommendations(data);
TableRow trow ;
TableCell tcell;
recommendedsites.Visible = true;
foreach (RecommendedWebsites recommendation in recommendationList)
{
Label1.Text = recommendation.getTitle();
trow = new TableRow ();
tcell= new TableCell ();
tcell.Controls.Add(new LiteralControl("<b>" + recommendation.getTitle() + "</b>"));
trow.Cells.Add(tcell);
tcell.Controls.Add(new LiteralControl("<p> <a href="" + recommendation.getLink() + ""</a>" + recommendation.getLink() + "</p>"));
trow.Cells.Add(tcell);
recommendedsites.Rows.Add(trow);
}
}
为什么不显示?我试过按一下按钮,表格出现了,没有任何问题
是一个asp.net数据控件(gridview或类似的东西),如果它是,你可能想添加推荐站点。databind ();