----------------------最终效果---------------------------

 

 -----------FreeTextBox使用方式---------------------

-----------中文汉化FreeTextBox相册-----------------

 

----------CS代码-----------------------------------------

 1 protected void Page_Load(object sender, EventArgs e)
2 {
3 if (!IsPostBack)
4 {
5 int aritcleId = int.Parse(Request.QueryString["articleId"]);
6 ArticleBLL artsystem = new ArticleBLL();
7 Article artdata = artsystem.GetNewInfo(aritcleId);
8 this.lblId.Text = artdata.ArticleId.ToString();
9 this.txtTitle.Text = artdata.Title;
10 this.txtClassId.Text = artdata.ClassId.ToString();
11 this.FreeTextBox1.Text = artdata.Content;
12 this.lblDateTime.Text = artdata.DateTime.ToString();
13 }
14 }
15
16 protected void btnEdit_Click(object sender, EventArgs e)
17 {
18 Article artdata = new Article();
19 artdata.ArticleId = int.Parse(this.lblId.Text);
20 artdata.Title = this.txtTitle.Text;
21 artdata.ClassId = int.Parse(this.txtClassId.Text);
22 artdata.Content = this.FreeTextBox1.Text;
23 artdata.DateTime = DateTime.Now;
24 ArticleBLL artsystem = new ArticleBLL();
25 artsystem.Edit(artdata);
26 this.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('修改成功!')</script>");
27 }

-----------BLL-----------------------------

-----------DAL----------------------------

 

posted @ 2012-02-13 22:48 阿杜008 阅读(128) 评论(0) 编辑

新闻删除模块几个功能

1. 显示当前的新闻。

2.使用选择框来确定需要删除的文章。

3.新闻标题通过超链接来链接到新闻修改模块中

 

----------最终效果界面--------------------------------

----------页面设计----------------------------------------

 

---------GridView 页面代码------------------------------------

 1 <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 
2 BackColor="White" BorderColor="#CCCCCC" BorderStyle="None" BorderWidth="1px"
3 CellPadding="3">
4 <RowStyle ForeColor="#000066" />
5 <Columns>
6 <asp:TemplateField HeaderText="ID" Visible="False">
7 <ItemTemplate>
8 <asp:Label ID="Id" runat="server" Text="<%#Bind('articleId') %>"></asp:Label>
9 </ItemTemplate>
10 </asp:TemplateField>
11 <asp:TemplateField HeaderText="新闻标题(点击修改)">
12 <ItemTemplate>
13 <a href='Article_Edit.aspx?articleId=<%#Eval("articleId") %>'><%# Eval("Title").ToString() %></a>
14 </ItemTemplate>
15 </asp:TemplateField>
16 <asp:BoundField DataField="DateTime" DataFormatString="{0:yyyy年MM月dd日}"
17 HeaderText="发布日期" />
18 <asp:BoundField DataField="ClassId" HeaderText="所属分类" />
19 <asp:TemplateField HeaderText="选择">
20 <ItemTemplate>
21 <asp:CheckBox ID="chk" runat="server" />
22 </ItemTemplate>
23 </asp:TemplateField>
24 </Columns>
25 <FooterStyle BackColor="White" ForeColor="#000066" />
26 <PagerStyle BackColor="White" ForeColor="#000066" HorizontalAlign="Left" />
27 <SelectedRowStyle BackColor="#669999" Font-Bold="True" ForeColor="White" />
28 <HeaderStyle BackColor="#006699" Font-Bold="True" ForeColor="White" />
29 </asp:GridView>

 

-------CS代码-----------------------

 1  protected void Page_Load(object sender, EventArgs e)
2 {
3 if (!IsPostBack)
4 {
5 BindGrideView();
6 }
7 }
8 protected void BindGrideView()
9 {
10 ArticleBLL artsystem = new ArticleBLL();
11 GridView1.DataSource = artsystem.GetAll();
12 GridView1.DataBind();
13 }
14 protected void Delete(int id)
15 {
16 ArticleBLL artsystem = new ArticleBLL();
17 artsystem.Delete(id);
18 BindGrideView();
19 }
20 protected void btnDelete_Click(object sender, EventArgs e)
21 {
22 //遍历GridView控件中所有选择的行
23 foreach (GridViewRow row in GridView1.Rows)
24 {
25 //如果其中的CheckBox被选中
26 if (((CheckBox)row.FindControl("chk")).Checked)
27 {
28 //调用方法删除被选中的行
29 int id = int.Parse(((Label)row.FindControl("id")).Text);
30 this.Delete(id);
31 }
32 }
33 this.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('删除成功!')</script>");


-----------BLL-----------------------------

-----------DAL----------------------------


 

posted @ 2012-02-13 22:40 阿杜008 阅读(123) 评论(0) 编辑