本文介绍了如何在gridview中编写搜索按钮的代码..我写下面的代码,但它有一些错误,所以如何写的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 这是我的代码 SqlConnection con = new SqlConnection(Data Source ...) protected void Page_Load(object sender ,EventArgs e) { BindEmployeeDetails(); } protected void BindEmployeeDetails() { con.Open(); SqlCommand cmd = new SqlCommand( select * from insertdetails,con); SqlDataAdapter da = new SqlDataAdapter(select * from insertdetails,con); DataSet ds = new DataSet(); da.Fill(ds,insertdetails); GridView1.DataSource = ds.Tables [insertdetails]; GridView1.DataBind(); con.Close(); } protected void Button1_Click(object sender,EventArgs e) { con.Open(); SqlCommand cmd1 = new SqlCommand(select * from insertdetails wher e username =''+ TextBox1.Text +'',con); BindndEmployeeDetails(); con.Close(); } 解决方案 this is my codeSqlConnection con= new SqlConnection("Data Source...) protected void Page_Load(object sender, EventArgs e) { BindEmployeeDetails();} protected void BindEmployeeDetails(){ con.Open(); SqlCommand cmd= new SqlCommand("select *from insertdetails",con); SqlDataAdapter da = new SqlDataAdapter("select *from insertdetails", con); DataSet ds= new DataSet(); da.Fill(ds,"insertdetails"); GridView1.DataSource = ds.Tables["insertdetails"]; GridView1.DataBind(); con.Close(); } protected void Button1_Click(object sender, EventArgs e) { con.Open(); SqlCommand cmd1= new SqlCommand(" select * from insertdetails where username=''"+TextBox1.Text+"''",con); BindndEmployeeDetails(); con.Close(); } 解决方案 这篇关于如何在gridview中编写搜索按钮的代码..我写下面的代码,但它有一些错误,所以如何写的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
10-30 07:59