/// <summary>
        /// The TopLevelList_Select server event handler is used to
        /// expand/collapse a selected discussion topic and delte individual items
        /// </summary>
        /// <param name="Sender"></param>
        /// <param name="e">DataListCommandEventAargs e</param>
        /// <returns>void return</returns>
        public void TopLevelListOrDetailList_Select(object Sender, DataListCommandEventArgs e)
        {
            // Determine the command of the button
            string command = ((System.Web.UI.WebControls.CommandEventArgs)(e)).CommandName;

            // Update asp:datalist selection index depending upon the type of command
            // and then rebind the asp:datalist with content
            switch (command)
            {
            case "CollapseThread":
            {
                TopLevelList.SelectedIndex = -1;                         // nothing is selected
                break;
            }

            case "ExpandThread":
            {
                TopLevelList.SelectedIndex = e.Item.ItemIndex;
                DiscussionDB discuss = new DiscussionDB();
                int          ItemID  = Int32.Parse(e.CommandArgument.ToString());
                discuss.IncrementViewCount(ItemID);
                break;
            }

            case "ShowThreadNewWindow":                     // open up the entire thread in a new window
            {
                TopLevelList.SelectedIndex = e.Item.ItemIndex;
                DiscussionDB discuss = new DiscussionDB();
                int          ItemID  = Int32.Parse(e.CommandArgument.ToString());
                discuss.IncrementViewCount(ItemID);
                Response.Redirect(FormatUrlShowThread(ItemID));
                break;
            }

            /*
             *      case "SelectTitle":
             *      TopLevelList.SelectedIndex = e.Item.ItemIndex;
             *      Response.Redirect(FormatUrlShowThread((int)DataBinder.Eval(Container.DataItem, "ItemID")));
             *      break;
             */
            case "delete":                      // the "delete" command can come from the TopLevelList or the DetailList
            {
                DiscussionDB discuss = new DiscussionDB();
                int          ItemID  = Int32.Parse(e.CommandArgument.ToString());
                discuss.DeleteChildren(ItemID);
                // DetailList.DataBind();	// synchronize the control and database after deletion
                break;
            }

            default:
                break;
            }
            BindList();
        }
Beispiel #2
0
        /// <summary> ThreadList_Select processes user events to add, edit, and delete topics </summary>
        /// <param name="Sender"></param>
        /// <param name="e">DataListCommandEventAargs e</param>
        /// <returns>returns nothing</returns>
        public void ThreadList_Select(object Sender, DataListCommandEventArgs e)
        {
            // Determine the command of the button
            string command = ((System.Web.UI.WebControls.CommandEventArgs)(e)).CommandName;

            switch (command)
            {
            case "delete":
                DiscussionDB discuss = new DiscussionDB();
                int          ItemID  = Int32.Parse(e.CommandArgument.ToString());
                discuss.DeleteChildren(ItemID);
                break;

            case "return_to_discussion_list":
                RedirectBackToReferringPage();
                break;

            default:
                break;
            }
            BindList(GetItemID());
            return;
        }