- 博客(0)
- 资源 (4)
- 收藏
- 关注
ASP.Net通讯录
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
ShowAll();
}
}
protected void btnSearch_Click(object sender, EventArgs e)
{
string key = this.txtkey.Text.Trim();//定义变量获取文本框值
if (key != "")
{
SqlConnection con = new SqlConnection();
con.ConnectionString = "Data Source=.;Initial Catalog=AddressList;Integrated Security=true";
con.Open();
SqlCommand cmd = new SqlCommand();
cmd.Connection = con;
cmd.CommandText = "select * from address_list where Name like '%" + key + "%'or Address like '%" + key + "%' or Email like '" + key + "' or Tel like '" + key + "'";
SqlDataReader dr = cmd.ExecuteReader();
this.GridView1.DataSource = dr;
this.GridView1.DataBind();
dr.Close();
con.Close();
}
else
{
ShowAll();
}
}
protected void btnAdd_Click(object sender, EventArgs e)
{
Response.Redirect("add.aspx");
}
2010-12-27
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人