//******************************************************* // // The BindList method obtains the list of top-level messages // from the Discussion table and then databinds them against // the "TopLevelList" asp:datalist server control. It uses // the ASPNetPortal.DiscussionDB() data component to encapsulate // all data access functionality. // //******************************************************* private void BindList() { // Obtain a list of discussion messages for the module // and bind to datalist ASPNetPortal.DiscussionDB discuss = new ASPNetPortal.DiscussionDB(); TopLevelList.DataSource = discuss.GetTopLevelMessages(ModuleId); TopLevelList.DataBind(); }
//******************************************************* // // The GetThreadMessages method is used to obtain the list // of messages contained within a sub-topic of the // a top-level discussion message thread. This method is // used to populate the "DetailList" asp:datalist server control // in the SelectedItemTemplate of "TopLevelList". // //******************************************************* protected IDataReader GetThreadMessages() { // Obtain a list of discussion messages for the module ASPNetPortal.DiscussionDB discuss = new ASPNetPortal.DiscussionDB(); IDataReader dr = discuss.GetThreadMessages(TopLevelList.DataKeys[TopLevelList.SelectedIndex].ToString()); // Return the filtered DataView return(dr); }
//******************************************************* // // The BindData method is used to obtain details of a message // from the Discussion table, and update the page with // the message content. // //******************************************************* void BindData() { // Obtain the selected item from the Discussion table ASPNetPortal.DiscussionDB discuss = new ASPNetPortal.DiscussionDB(); IDataReader dr = discuss.GetSingleMessage(itemId); // Load first row from database dr.Read(); // Update labels with message contents Title.Text = (String)dr["title"]; Body.Text = (String)dr["body"]; CreatedByUser.Text = (String)dr["createdbyuser"]; CreatedDate.Text = String.Format("{0:d}", dr["createddate"]); TitleField.Text = ReTitle(Title.Text); int prevId = 0; int nextId = 0; // Update next and preview links object id1 = dr["prevmessageid"]; if (id1 != null && id1 != DBNull.Value) { prevId = (int)id1; prevItem.HRef = Request.Path + "?ItemId=" + prevId + "&mid=" + moduleId; } object id2 = dr["nextmessageid"]; if (id2 != null && id2 != DBNull.Value) { nextId = (int)id2; nextItem.HRef = Request.Path + "?ItemId=" + nextId + "&mid=" + moduleId; } // close the datareader dr.Close(); // Show/Hide Next/Prev Button depending on whether there is a next/prev message if (prevId <= 0) { prevItem.Visible = false; } if (nextId <= 0) { nextItem.Visible = false; } }