/// <summary> /// 绑定数据源 /// </summary> public void GetPageList() { BLL.ArticleManagement article = new BLL.ArticleManagement(); DataSet ds = article.GetListByPage("", "Uploadtime desc", (AspNetPager1.CurrentPageIndex - 1) * AspNetPager1.PageSize + 1, (AspNetPager1.CurrentPageIndex) * AspNetPager1.PageSize); //进行分页操作 AspNetPager1.RecordCount = article.GetRecordCount(""); //对控件进行数据绑定 Repeater1.DataSource = ds; Repeater1.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { int id = Request["id"] == null ? 0 : int.Parse(Request["id"]); BLL.ArticleManagement article = new BLL.ArticleManagement(); Model.ArticleManagement model = new Model.ArticleManagement(); model = article.GetModel(id); title = model.Title; keyword = model.Keyword; contents = model.Content; image = model.Image; time = Convert.ToDateTime(model.Uploadtime).ToString("yyyy-mm-dd"); }
/// <summary> /// 删除操作 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public void Del(object sender, EventArgs e) { int id = int.Parse((sender as LinkButton).CommandArgument); //得到对应的按钮 BLL.ArticleManagement article = new BLL.ArticleManagement(); bool a = article.Delete(id); if (a == true) { Repeater1.DataSource = article.GetList(""); Repeater1.DataBind(); } else { Response.Write("删除失败!"); } }
protected void Page_Load(object sender, EventArgs e) { int id = Request["id"] == null ? 0 : int.Parse(Request["id"]); BLL.ArticleManagement management = new BLL.ArticleManagement(); Model.ArticleManagement model; model = management.GetModel(id); Content = model.Content; title = model.Title; Keyword = model.Keyword; DateTime?time = model.Uploadtime; //因为数据库中有可能时间为空,所以用 datetiem?类型 Time = Convert.ToDateTime(time).ToString("yyyy-MM-dd"); //转化成约定的时间格式 //Response.Write(model.Content); 避免respons.write的方式,因为它不可控制 //DataSet ds = management.GetList(" id="+id.ToString()); //Response.Write(ds.Tables[0].Rows[0][3]); }