This is a migrated thread and some comments may be shown as answers.

How to bind list view on textbox changes

1 Answer 202 Views
ListView
This is a migrated thread and some comments may be shown as answers.
Dharmesh
Top achievements
Rank 1
Dharmesh asked on 18 Jan 2012, 03:01 PM
hello,

 i want bind the listview on textbox change 

i mean when i type any word then listview bind data from my database and refresh on next world on textbox when i type

i am not get any help 
so please tell me some idea or code 

thanks

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 19 Jan 2012, 08:43 AM
Hello,

Try the following code snippet to bind ListView on TextBox change.
C#:
protected void txt_TextChanged(object sender, EventArgs e)
   {
       TextBox txt = (TextBox)sender;
       string t = txt.Text;
       int t1 = Convert.ToInt16(t);
       SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["NorthwindConnectionString"].ToString());
       String s = "select FirstName,EmployeeID from Employees where EmployeeID='"+t1+"'";
       con.Open();
       SqlDataAdapter dr = new SqlDataAdapter(s, con);
       DataTable dt = new DataTable();
       dr.Fill(dt);
       con.Close();
       RadListView lst = (RadListView)txt.FindControl("ListBox1");
       lst.DataSource = dt;
       lst.DataBind();
   }

Thanks,
Princy.
Tags
ListView
Asked by
Dharmesh
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or