📄 manageghdw.aspx.cs
字号:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
public partial class manageghdw : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
gridviewBind();
}
}
//gridview绑定
private void gridviewBind()
{
string str = "select * from ghdw order by gongID desc";
SqlConnection scon = new SqlConnection(ConfigurationManager.AppSettings["ConnectionString"]);
scon.Open();
SqlDataAdapter dbAdapter = new SqlDataAdapter(str, scon);
DataSet ds = new DataSet();
dbAdapter.Fill(ds);
scon.Close();
GridView1.DataSource = ds.Tables[0].DefaultView;
GridView1.DataKeyNames = new string[] { "gongID" };
GridView1.DataBind();
}
////f分页
protected void GridView1_PageIndexChanging1(object sender, GridViewPageEventArgs e)
{
GridView1.PageIndex = e.NewPageIndex;
GridView1.DataBind();
gridviewBind();
}
protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
string ss = "delete from ghdw where gongID='" + this.GridView1.DataKeys[e.RowIndex].Value.ToString() + "'";
SqlConnection scon = new SqlConnection(ConfigurationManager.AppSettings["ConnectionString"]);
scon.Open();
SqlCommand scmd = new SqlCommand(ss, scon);
scmd.ExecuteNonQuery();
scon.Close();
GridView1.DataBind();
gridviewBind();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -