?? spkccx.aspx.cs
字號(hào):
?using System;
using System.Data;
using System.Data.SqlClient;
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;
public partial class spkccx : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
//是否第一次加載頁(yè)面
if (!Page.IsPostBack)
bindgrig();
}
protected void Button1_Click(object sender, EventArgs e)
{
//查詢符合條件的記錄,默認(rèn)第一頁(yè)
GridView1.PageIndex = 0;
bindgrig();
}
void bindgrig()
{
SqlConnection Conn;
// 設(shè)置數(shù)據(jù)庫(kù)連接
string strConn = ConfigurationManager.AppSettings["conn"];
Conn = new SqlConnection(strConn);
//從數(shù)據(jù)庫(kù)取查詢結(jié)果
SqlDataAdapter Cmd = new SqlDataAdapter("select * from 商品庫(kù)存 where 商品編號(hào) like '%" + this.TextBox1.Text + "%' and 商品名稱 like '%" + this.TextBox2.Text + "%'", Conn);
DataSet Ds = new DataSet();
Cmd.Fill(Ds, "商品庫(kù)存");
//指定數(shù)據(jù)源
GridView1.DataSource = new DataView(Ds.Tables[0]);
//數(shù)據(jù)綁定
GridView1.DataBind();
}
protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
//改變顯示頁(yè)面
GridView1.PageIndex = e.NewPageIndex;
bindgrig();
}
}
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -