My C # Article module code

Source: Internet
Author: User

Wherever you are, you have to deal with the article module .....

Announcements, news, and stories ....

Now I am going to publish an article module for my own use, even if it is a reference...

Front-end

Front-end

<Asp: repeater ID = "categorymainr" runat = "server" OnItemDataBound = "categorymainr_ItemDataBound"> <ItemTemplate> <div class = "cnt2_pages_main"> <ul class = "comtabs3"> <li> a target = "_ blank" class = "current" href = "wzlist. aspx? Categoryid = <% # Eval ("id") %> "> <% # Eval (" categoryname ") %> </a> </li> <p style = "float: right; text-align: right "> <a target =" _ blank "class =" current "href =" wzlist. aspx? Categoryid = <% # Eval ("id ") %> ">  </a> </p> </ul> <div class =" cnts"> <asp: repeater ID = "newsmainr" runat = "server"> <ItemTemplate> <div class = "textArea"> <ul class = "ArticleUl"> <li> <a target = "_ blank "title =" <% # Eval ("title ") %> "href = \ '# \'" Eval ("id") %> "> <% # Eval (" title "). toString (). length <22? Eval ("title"): Eval ("title "). toString (). substring (0, 20) + "... "%> </a> <span class =" short_date "> <% # Convert. toDateTime (Eval ("posttime ")). toString ("MM-dd") %> </span> </li> </ul> </div> </ItemTemplate> </asp: repeater> </div> </ItemTemplate> </asp: Repeater>

Code... You can only blame this editor... Too bad... The front-end is nested with two repeater ..

Categorymainr is responsible for the output of article categories, while newsmainr is responsible for the output of the specific number of article titles of each category.

Background


Binding category:
categorymainr.DataSource = w_categoryBLL.SelectCategoryAll();categorymainr.DataBind();

Bind an article:

protectedvoid categorymainr_ItemDataBound(object sender, RepeaterItemEventArgs e)        {if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)            {Repeater newsmainr = (Repeater)e.Item.FindControl("newsmainr");int id = Convert.ToInt32(DataBinder.Eval(e.Item.DataItem, "id").ToString());                newsmainr.DataSource = w_newsBLL.selectNewsByPage(-1, id, 1, 10);                newsmainr.DataBind();            }        }


This article is from the blog "Yang guoguo nest", please be sure to keep this http://7219914.blog.51cto.com/7209914/1210577

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.