asp.net web page WebGrid分类显示问题
请问一下如何写一个方法使分类在 WebGrid 中这样排序显示:父级分类后面显示子分类。(就像TreeView那样,只不过呢我是用在WebGrid)最终效果如图:
回答
问题补充:
@{ var db = Database.Open("rcdb") ; var selectCommand = "SELECT * FROM City ORDER BY Id"; var searchTerm = ""; if(!Request.QueryString["searchTitle"].IsEmpty() ) { selectCommand = "SELECT * FROM City WHERE Name LIKE @0"; searchTerm = "%" + Request["searchTitle"] + "%"; } var selectedData = db.Query(selectCommand, searchTerm); var grid = new WebGrid(source: selectedData, rowsPerPage: 20); }