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

    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
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 19 Jan 2012 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top