How to bind list view on textbox changes

2 posts, 0 answers
  1. Dharmesh
    Dharmesh avatar
    9 posts
    Member since:
    Jul 2012

    Posted 18 Jan 2012 Link to this post


     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 

  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 19 Jan 2012 Link to this post


    Try the following code snippet to bind ListView on TextBox change.
    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+"'";
           SqlDataAdapter dr = new SqlDataAdapter(s, con);
           DataTable dt = new DataTable();
           RadListView lst = (RadListView)txt.FindControl("ListBox1");
           lst.DataSource = dt;

Back to Top