Hello,

I am currently completing a side project. The biggest ideal of it all has to do with a dynamic drop down box. I have heard and seen of the 'auto complete textbox' feature by using ajax/jquery toolkits. That is what I'm looking for, but I was wondering if there is any way of a simple way to do it? Below is what I have so far. I am connected to SQL Server database and can retrieve information based off the columns, but only one at a time. My two questions are asked below. Any tips or more feedback would be greatly appreciated!

http://i.stack.imgur.com/7X56V.png[^]

http://i.stack.imgur.com/Rj4a3.png[^]

I'm only searching by "First_Name" characters only. If I were to search for "Last_Name", "Gender" or "Age" it wouldn't work unless I deleted the First_Name column from the code and replaced it with a new column name. That is why I am asking is there any way I could include all four columns in the code above to ensure everything would be searchable?

And this is what I mean by 'dynamic'. http://kmplot.com/analysis/index.php?p=service&cancer=ovar
The link above better illustrates. You randomly start typing characters in the "Affy id/Gene symbol" textbox and receive an unlimited options of sequences to choose from. This is where I'm stuck and need to implement this type of method into my project.

My back end code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;

public partial class _Default : System.Web.UI.Page
{
    SqlConnection con = new SqlConnection("Data Source=SKYNET-1000\\SQLEXPRESS;Initial Catalog=CSC_480;Integrated Security=True"); 



    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        String str = "select * from People where (First_Name like '%' + @search + '%')";
        SqlCommand win7 = new SqlCommand(str, con);
        win7.Parameters.Add("@search", SqlDbType.NVarChar).Value = TextBox1.Text;


        con.Open();
        win7.ExecuteNonQuery();
        SqlDataAdapter da = new SqlDataAdapter();
        da.SelectCommand = win7;
        DataSet ds = new DataSet();
        da.Fill(ds, "First_Name");
        GridView2.DataSource = ds;
        GridView2.DataBind();
        con.Close();
    }
}

You can search as many columns as you want if you think the input is going to vary. You just want to only return one column and make sure the result set is distinct so you don't have multiple instances of the same name appearing in the list.
Say, for example, you want to return first name. You could create a query that searched for the partial text in first_name, last_name, age. depending on the criteria this could return a larger set than just searching first name. But as long as you filtered the result ser to remove duplicates, you still get a usable list as a result.
is that along the lines of what you are after?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.