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