htmlSorts 爲全局變量 public string FormSorts(string sortid,string eid) { htmlSorts = "<select name=/"sort"+eid+"/" id=/"sort/" >"; htmlSorts += "<option value=0 >根目錄</option>"; FormChildSort("0", "," + sortid + ","); htmlSorts += "</select>"; return htmlSorts; } public void FormChildSort(string id, string sortid) { DataTable dtChildSort; dtChildSort = Modulesql.CreateDataSetaaCH("SELECT * FROM sort where parentid=" + id + " order by id", "sort").Tables[0]; if (!(dtChildSort.Rows.Count == 0)) { for (int i = 0; i < dtChildSort.Rows.Count; i++) { if (sortid.IndexOf("," + dtChildSort.Rows["id"].ToString() + ",") >= 0) htmlSorts = htmlSorts + "<option value=" + dtChildSort.Rows["id"].ToString() + " selected >" + (new string(' ', System.Convert.ToInt32(dtChildSort.Rows["layer"]))) + dtChildSort.Rows["sort"].ToString() + "</option>"; else htmlSorts = htmlSorts + "<option value=" + dtChildSort.Rows["id"].ToString() + " >" + (new string(' ', System.Convert.ToInt32(dtChildSort.Rows["layer"]))) + dtChildSort.Rows["sort"].ToString() + "</option>"; FormChildSort(dtChildSort.Rows["id"].ToString(), sortid); } } } 調用方法:FormSorts(選中的id,選中的id);
自己寫無限極欄目,用了一個精彩的迭代
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章
轉全角半角互相轉換(C#,VB.NET)
yuxuan0476
2018-08-23 02:24:35
如何用正則表達式移除script中的腳本
yuxuan0476
2018-08-23 02:24:34
密碼強度的驗證
yuxuan0476
2018-08-23 02:24:34
asp.net neatUpload 支持大文件上傳組件
yuxuan0476
2018-08-23 02:24:34
ASP.NET中用HttpPostedFile.SaveAs(FileName)方法上傳文件,文件大小限制
yuxuan0476
2018-08-23 02:24:33