protected void Page_Load(object sender, EventArgs e) { DBSQL db = new DBSQL(); System.Data.DataTable dt = new System.Data.DataTable(); dt=db.TSelect("TBoardMain",null,true); foreach (DataRow row in dt.Rows) { HtmlGenericControl li = new HtmlGenericControl("li"); navbar.Controls.Add(li); HtmlGenericControl anchor = new HtmlGenericControl("a"); string sBoardName = row["BoardName"].ToString(); anchor.Attributes.Add("href", "ViewBoard.aspx?BoardName=" + sBoardName); anchor.InnerText = sBoardName; li.Controls.Add(anchor); } }
protected void RetrieveBoardList() { System.Data.DataTable dt = new System.Data.DataTable(); DBSQL dbsql = new DBSQL(); dt = dbsql.TSelect("TBoardMain",null, true); try { if (dt.Rows.Count != 0) { gvBoardList.DataSource = dt; gvBoardList.DataBind(); } }catch(Exception e) { gvBoardList.DataSource = dt; gvBoardList.EmptyDataText = "No board to retrieve"; gvBoardList.DataBind(); } }