protected void Button1_Click(object sender, EventArgs e)
{
string sSql = "insert into News(Title,Contents,Publisher,Sort) values('" + TextBox1.Text + "','" + TextBox2.Text + "','" + Session["Users"].ToString() + "','" + DropDownList1.Text + "')";
SQL s = new SQL();
bool result = s.SqlResults(sSql);
if (result == true)
{
TextBox1.Text = "";
TextBox2.Text = "";
Page.RegisterStartupScript("alert", "<script>alert('添加成功!');</script>");
}
else
{
Page.RegisterStartupScript("alert", "<script>alert('添加失败!');</script>");
}
}
4.3 信息修改设计及实现
信息修改页面主要是针对已添加的信息进行相关信息的修改。页面设计如图4.3所示。
图4.3 信息修改页面
点击‘编辑’后,可进入到内容修改页面,如图4.4所示。
图4.4 撰写修改页面
通过对之前已经添加进入数据库的信息内容的调用来实现该步中对信息修改的操作,修改完成的信息将添加到数据库中并覆盖之前信息的内容,发布时间等信息。系统功能实现的关键代码如下:
//信息检索
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
bind();
}
}
private void bind()
{
string sSql = "select * from News where Checks=0";
SQL s = new SQL();
DataSet ds = s.DSSearch(sSql);
GridView1.DataSource = ds.Tables[0].DefaultView;
GridView1.DataKeyNames = new string[] { "id" };
GridView1.DataBind();
}
protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
GridView1.PageIndex = e.NewPageIndex;
bind();
}
protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
{
string id = GridView1.DataKeys[e.NewEditIndex].Value.ToString();
Response.Redirect("News_editdetail.aspx?id="+id);
}
//信息更新
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
- 上一篇:Html5+CSS3川南苗族文化传播网站的分析设计与开发+ER图+流程图
- 下一篇:C#公司考勤管理系统设计+可行性研究+需求分析
-
-
-
-
-
-
-
大众媒体对公共政策制定的影响
电站锅炉暖风器设计任务书
杂拟谷盗体内共生菌沃尔...
十二层带中心支撑钢结构...
当代大学生慈善意识研究+文献综述
中考体育项目与体育教学合理结合的研究
河岸冲刷和泥沙淤积的监测国内外研究现状
java+mysql车辆管理系统的设计+源代码
酸性水汽提装置总汽提塔设计+CAD图纸
乳业同业并购式全产业链...