日期:2014-05-17 浏览次数:20611 次
public static IEnumerable<Article> ListArticle() { List<Article> articles = new List<Article>(); using (SqlConnection connection = new SqlConnection(connectionString)) { string commandText = "select * from He_Article where Deleted = 0"; using (SqlCommand command = new SqlCommand(commandText, connection)) { connection.Open(); SqlDataReader reader = command.ExecuteReader(); while (reader.Read()) { Article article = new Article(); article.ID = (int)reader["ID"]; article.ClassID = (int)reader["ClassID"]; article.Title = (string)reader["Title"]; article.Author = (string)reader["Author"]; article.CopyFrom = (string)reader["CopyFrom"]; article.Keyword = (string)reader["Keyword"]; article.Hits = (int)reader["Hits"]; article.UpdateTime = (DateTime)reader["UpdateTime"]; article.OnTop = (int)reader["OnTop"]; article.Elite = (int)reader["Elite"]; article.Status = (int)reader["Status"]; article.Content = (string)reader["Content"]; article.DefaultPicUrl = (string)reader["DefaultPicUrl"]; article.Deleted = (int)reader["Deleted"]; articles.Add(article); } reader.Close(); connection.Close(); } } return articles; }
public ActionResult Admin_Article_Manage() { ViewData["ManageList"] = ArticleDataContext.ListArticle(); return View(); }
<%foreach (Article article in this.ViewData["ManageList"] as IEnumerable<Article>){%> <tr> <td><%:Html.CheckBox("ID")%></td> <td><%=article.ID%></td> <td align="left">[<%=article.ClassID%>]<%=article.Title%></td> <td><%=article.Author%></td> <td><%=article.Hits%></td> <td><%=article.ID%></td> <td><%=article.Status%></td> <td>修改 删除 固定 设为推荐</td> </tr> <%}%>
public ActionResult Index(int? id = 1) { var count = db.Article.Count(); var article = db.Article.OrderByDescending(m => m.ID) .Skip(20 * Convert.ToInt32(id - 1)) .Take(20); ViewBag.Current = id; ViewBag.Count = (count % 20 == 0) ?