private TreeView CreateMessageTree()
        {
            tvMessages.Nodes.Clear();
            SQLModule sQLModule = new SQLModule();
            DataTable dt        = sQLModule.GetAllMessages();
            TreeView  result    = new TreeView();

            IEnumerable <Item> items = from item in dt.AsEnumerable()
                                       select new Item
            {
                ID       = item.Field <int>("ID"),
                Message  = item.Field <string>("Message"),
                ParentID = item.Field <int?>("ParentMessageID")
            };

            IEnumerable <Item> parent = from item in dt.AsEnumerable()
                                        where item.IsNull("ParentMessageID")
                                        select new Item {
                ID       = item.Field <int>("ID"),
                Message  = item.Field <string>("Message"),
                ParentID = item.Field <int?>("ParentMessageID")
            };

            foreach (Item item in parent.ToList())
            {
                TreeNode tvi = new TreeNode(item.Message);
                tvi.ToolTip = item.ID.ToString();
                BuildChildNodes(tvi, items.ToList(), item.ID);
                tvMessages.Nodes.Add(tvi);
            }

            return(result);
        }
        protected void btnSave_Click(object sender, EventArgs e)
        {
            if (txtMessage.InnerText.Trim() == "")
            {
                return;
            }
            SQLModule sQLModule = new SQLModule();

            if (MessageID.Value == "")
            {
                sQLModule.AddMessage(txtMessage.Value.ToString());
            }
            else
            {
                sQLModule.AddMessage(txtMessage.Value.ToString(), Int32.Parse(MessageID.Value));
            }
            MessageID.Value = "";
            DisplayMessages();
            txtMessage.InnerText = "";
        }