예제 #1
0
        protected void Page_Init(object sender, EventArgs e)
        {
            BlogCategoryDAL categoryDAL = new BlogCategoryDAL();
            BlogEntryDAL entryDAL = new BlogEntryDAL();

            //setup the accordion
            this.Accordion.Panes.Clear();
            foreach (BlogCategory category in categoryDAL.ReadBlogCategory(BlogTopic))
            {
                AjaxControlToolkit.AccordionPane pane = new AjaxControlToolkit.AccordionPane();
                pane.ID = "pane" + category.Id;

                LiteralControl header = new LiteralControl(string.Format("<div class = \"MenuHeader\"><b>{0}</b></div>", category.Category));

                pane.HeaderContainer.Controls.Add(header);
                pane.ContentContainer.Controls.Add(new LiteralControl("<ul style='margin-top:0; margin-bottom:0'>"));
                foreach (BlogEntry entry in entryDAL.GetBlogEntries(category.Id))
                {
                    LinkButton linkButton = new LinkButton();
                    linkButton.ID = "linkButton" + entry.Id;
                    linkButton.Text = entry.Subject;
                    linkButton.CommandArgument = entry.Id.ToString();
                    linkButton.Command += new CommandEventHandler(linkButton_Command);
                    linkButton.CausesValidation = false;
                    linkButton.CssClass = "MenuButton";
                    pane.ContentContainer.Controls.Add(new LiteralControl("<li>"));
                    pane.ContentContainer.Controls.Add(linkButton);
                    pane.ContentContainer.Controls.Add(new LiteralControl("</li>"));
                }
                pane.ContentContainer.Controls.Add(new LiteralControl("</ul>"));
                this.Accordion.Panes.Add(pane);
            }
        }
예제 #2
0
 private void PopulateDdlCategory(int BlogTopicID)
 {
     DropDownList ddlCategory = (DropDownList)DetailsView1.FindControl("ddlCategory");
     ddlCategory.Items.Clear();
     BlogCategoryDAL categoryBLL = new BlogCategoryDAL();
     foreach (var item in categoryBLL.ReadBlogCategory(BlogTopicID))
     {
         ddlCategory.Items.Add(new ListItem(item.Category, item.Id.ToString()));
     }
 }