0
我想填充page_load中的表,但沒有任何顯示,我知道我有來自數據庫的結果。這裏是我的代碼:表不會顯示從頁面加載時填充
p
rotected void Page_Load(object sender, EventArgs e)
{
StreamReader reader = new StreamReader(Page.Request.InputStream);
data = reader.ReadToEnd();
reader.Close();
string queryKeys = "";
if (data != "")
{
string[] IDs = data.TrimEnd().Split(' ');
SQLiteConnection sqlite_connectionUM = new SQLiteConnection("Data Source=" + path_to_um + ";Version=3;");
sqlite_connectionUM.Open();
foreach (string ID in IDs)
{
SQLiteCommand sqlite_queryMax = sqlite_connectionUM.CreateCommand();
sqlite_queryMax.CommandText = "SELECT Keywords.Word from Keywords where Cluster = @c ORDER BY Keywords.Score LIMIT 5";
sqlite_queryMax.Parameters.Add(new SQLiteParameter("@c", IDs[0]));
SQLiteDataReader keywords = sqlite_queryMax.ExecuteReader();
while (keywords.Read())
{
queryKeys += keywords.GetString(0) + " ";
}
showRecommendations(queryKeys);
}
queryKeys = "";
}
}
這是我showRecommendations方法:
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);
}
}
爲什麼沒有顯示?我試圖用一個按鈕正常點擊,並表出現沒有任何問題
什麼是你的代碼推薦的網站? – 2011-04-28 09:42:30
怎麼樣在Page_Init – V4Vendetta 2011-04-28 09:47:50
這樣做推薦的網站是 – michelle 2011-04-28 09:53:39