我有一個樹形視圖格式類型的側面導航菜單。我面臨的問題是側面導航欄應該適應數據庫中的數據。我寫了下面的代碼。動態菜單數據
private void GetMenuData()
{
DataTable table = new DataTable();
string cs = System.Configuration.ConfigurationManager.ConnectionStrings["myconectionstring"].ConnectionString;
SqlConnection conn = new SqlConnection(cs);
string sql = "select SiteName from SiteMaster";
SqlCommand cmd = new SqlCommand(sql, conn);
SqlDataAdapter da = new SqlDataAdapter(cmd);
da.Fill(table);
DataView view = new DataView(table);
foreach (DataRowView row in view)
{
sites.InnerHtml= Server.HtmlDecode("<li><a href='#'><i class='fa fa-circle-o text-warning'></i>" + row["SiteName"].ToString() + "</a></li>");
}
}
SiteMaster表包含SiteName列表。這裏的問題是隻有最後一個SiteName被顯示在側面菜單中。我希望顯示SiteName列下的所有行。
網站是ID爲<ul>
你需要因此它的可讀性格式化你的代碼! – Matt
我很抱歉,我只是從VS複製粘貼。 – pratheek