代码拉取完成,页面将自动刷新
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Configuration;
using System.Data.SqlClient;
public partial class codelist : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
//删除
protected void gv_department_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
string sqlstr = "delete from t_department where idepartment_ID='" + gv_department.DataKeys[e.RowIndex].Value.ToString() + "'";
string str = ConfigurationManager.ConnectionStrings["DevMgmntConnectionString"].ConnectionString.ToString();
SqlConnection cn33 = new SqlConnection(str);
cn33.Open();
SqlCommand sqlcom = new SqlCommand(sqlstr, cn33);
sqlcom.ExecuteNonQuery();
cn33.Close();
gv_department.DataBind();
}
protected void bt_departmentAdd_Click(object sender, EventArgs e)
{
TextBox t1 = tx_departmentID;
TextBox t2 = tx_departmentName;
try
{
string str = ConfigurationManager.ConnectionStrings["DevMgmntConnectionString"].ConnectionString.ToString();
SqlConnection cn33 = new SqlConnection(str);
cn33.Open();
str = "insert INTO t_department (idepartment_ID,sdepartmentName) values ('" + t1.Text.Trim() + "','" + t2.Text.Trim() + "')";
Console.WriteLine("btn_departmentAdd:{0}", str);
SqlCommand cmd2 = new SqlCommand(str, cn33);
cmd2.ExecuteNonQuery();
cn33.Close();
}
catch (Exception ex)
{
Console.WriteLine("传递过来的异常值为:{0}", ex);
}
gv_department.DataBind();
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。