從資料庫讀出資料動態生成選單欄

2021-06-10 09:04:47 字數 2498 閱讀 2362

注:這個是當初水平有限比較初級的 ,,後來後來 就 有相對高階點的參考

dbunitly層:
using system;

using system.collections.generic;

using system.linq;

using system.text;

using system.data.sqlclient;

using system.configuration;

using system.web;

using system.data;

namespace dbunitly

catch(system.data.sqlclient.sqlexception e)}}

}/// /// 執行查詢語句,返回dataset

///

/// 查詢語句

/// dataset

public static dataset query(string sqlstring)

catch (system.data.sqlclient.sqlexception ex)

return ds;}}

}}

dal層:
_menumanager類

using system;

using system.collections.generic;

using system.linq;

using system.text;

using system.data;

namespace dal

else

if (!string.isnullorempty(strwhere.trim()))

return dbunitly.dbhelp.query(strsql.tostring());

}/// /// 獲得資料列表

///

public dataset getlist(string strwhere)

return dbunitly.dbhelp.query(strsql.tostring());}}

}_menuchildrenmanager類

using system;

using system.collections.generic;

using system.linq;

using system.text;

using system.data;

namespace dal

return dbunitly.dbhelp.query(sb.tostring());

// select mc_name from _menuchildren where menu_type in( select menu_id from _menu );}}

}

bll層:
_menuservice類

using system;

using system.collections.generic;

using system.linq;

using system.text;

using system.data;

namespace bll

/// /// 獲得資料列表

///

///

///

public dataset getlist(string strwhere)

}}_menuchildrenservice

using system;

using system.collections.generic;

using system.linq;

using system.text;

using system.data;

namespace bll

}}

test層:
menutest.aspx

.cs檔案

using system;

using system.collections.generic;

using system.linq;

using system.web;

using system.web.ui;

using system.web.ui.webcontrols;

using system.data;

public partial class menutest : system.web.ui.page

menunode.enabled = true;

menu1.items.add(menunode);}}

}}

有原始碼:

選單欄根據後台資料自動生成

最近遇到乙個問題 需要給個人分許可權檢視不同的選單 以前許可權問題是定義乙個資料庫表 根據許可權不同賦予不同的許可權 從資料庫獲取選單 比較靈活 所以就做了這個肯定有很多不足 希望可以和大家共同學習 技術 easyui spring spingmvc mybiatis 為什麼要用easyui呢 因為...

從資料庫動態載入選單

一 資料庫設計 系統選單表 column type comment idint 選單編號 menu name varchar 一級選單名 menu num varchar 所屬的一級選單編號 picture varchar 選單url varchar 選單鏈結 is use int是否使用 sort...

從資料庫讀出資料分頁顯示

從資料庫中把資料讀出來 再渲染到頁面上 defbook view request book list book.objects.all return render request,book view.html 把讀取的內容交給頁面,然讓頁面交給瀏覽器 book list book.objects.a...