假设查询按钮的ID是btnSelectName,数据库中的瞎激这敬早个表名是 TB_User, 而表示用亮神雀户姓名的字段是UserName ,
在按钮事件写:(随手写得~~~~~~~)
protected void btnSelectName_Click(Object sender, Event e)
{
string strName = this.TextBox1.Text.Trim();
string strSql =string.Format( "select * from TB_User where UserName ='{0}' ",strName ); //主要是字符串拼接,使用string.Format()
SqlDapaAater sda = new SqlDapaAater (strSql,conn);
DataSet ds = new DataSet();
sda.Fill(ds);
gridview1.DataSource = ds.Tables[0];
gridview1.Databind();
}
select * from shujuku where id='"缺伏+((textbox)(gridview1.datakeys[e.rowindex].cols[0].control[0].tostring()+"备唯'伏滚携