/// <summary> /// 加载标签 /// </summary> /// <param name="tag"></param> private void LoadTag(string type, string tag) { // 加载标签 mdb.Connect(); DataSet data = new DataSet(); OleDbDataAdapter tagTable = MyPostUtils.GetArticleTagByUserId(GetUserInfo().userID, type, mdb.GetConn); tagTable.Fill(data, "TagTable"); mdb.Disconnect(); if (data != null) { // 绑定数据到 TagDDList 控件上 TagDDList.DataSource = data.Tables["TagTable"].DefaultView; TagDDList.DataTextField = "Tag"; TagDDList.DataValueField = "Tag"; TagDDList.DataBind(); TagDDList.Items.Insert(0, new ListItem(tag, tag)); // 释放资源 data.Dispose(); tagTable.Dispose(); } LoadTotalOrders(type, tag); }
/// <summary> /// 加载页面数据 /// </summary> private void LoadTotalOrders(string type, string tag) { User user = GetUserInfo(); if (user != null) { // 加载文章数量 mdb.Connect(); ArticleCount = MyPostUtils.GetUserArticleCountByUserId(user.userID, type, mdb.GetConn); AspNetPager.RecordCount = ArticleCount; mdb.Disconnect(); } Total.Text = "( " + type + ":" + ArticleCount + " 贴 )"; DataBindToPostRepeater(type, tag); }
/// <summary> /// 根据当前登录用户Id获取用户草稿信息 /// 并将数据绑定到 Repeater_Draft控件上 /// </summary> private void DataBindToPostRepeater(string type, string tag) { User user = GetUserInfo(); if (user != null) { int startI = AspNetPager.StartRecordIndex; // 表的起始位置 int endI = AspNetPager.EndRecordIndex; // 表的结束位置 if (endI <= 0) { endI++; } int startIndex = (endI - startI + 1); int endIndex = endI; mdb.Connect(); // 根据用户id获取用户文章指定范围的文章信息 Repeater_Post.DataSource = MyPostUtils.GetMyPostByOders(startIndex, endIndex, user.userID, type, tag, mdb.GetConn); Repeater_Post.DataBind(); mdb.Disconnect(); } }