コード例 #1
0
        //修改新闻
        protected void UpdateNews_Click(object sender, EventArgs e)
        {
            News news = new News();

            news.News_ID1        = Convert.ToInt32(Request.QueryString["newsid"].ToString());
            news.News_Title1     = txtTitle.Text.Trim();
            news.News_Time1      = DateTime.Parse(DateTime.Now.ToShortDateString().ToString());
            news.News_Conentent1 = txtContent.Text;
            news.News_Num1       = int.Parse(txtNum.Text.Trim());
            news.News_Img1       = @"~/Img_News/" + FileUpload1.PostedFile.FileName;

            news.News_Class1 = DropDownList_Class.SelectedItem.Text.Trim();
            try
            {
                if (NewsBll.Updatenews(news) == 1)
                {
                    Page.ClientScript.RegisterClientScriptBlock(typeof(Object), "alert", "<script>alert('修改成功!');</script>");
                }
                else
                {
                    Page.ClientScript.RegisterClientScriptBlock(typeof(object), "alert", "<script>alert('修改失败!');</script>");
                }
            }
            catch (Exception ex)
            {
                Response.Write("错误原因:" + ex.Message);
            }
        }