title: Textbox autocomplete for web application c#
body: <p>I've got a dropdown/ textbox combination to enable the user to filter the data of a <code>GridView</code>.
  So the user would select the option 'Job Title' in the dropdown and then enter the Job title they are looking for in the <code>textbox</code>. However, I want to give the user a list of suggestion of Job titles. I've been trying to do so with <code>AutoCompleteMode</code> set to <code>SuggestAppend</code> and a <code>AutoCompleteSource</code> set to custom but this hasn't been working and I get the error that <code>AutoCompleteMode</code> etc. doesn't exist in the current context. </p>
  
  <p>This is the code in my TextBox1 Changed event :</p>
  
  <pre><code> TextBox1.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
   t=TextBox1.AutoCompleteSource = AutoCompleteSource.CustomSource;
   AutoCompleteStringCollection DataCollection = new AutoCompleteStringCollection();
   addItems(DataCollection);
   TextBox1.AutoCompleteCustomSource = DataCollection;
  </code></pre>
  
  <p>And this to set the autocomplete options:</p>
  
  <pre><code> var source = new AutoCompleteStringCollection();
   source.AddRange(new string[]
                      {
                      "Marketing",
                      "Engineer",
                      "Medical",
                      "Insurance",                        
                      });
  </code></pre>
  
  <p>I'm currently filtering the data with the <code>dropdown</code> list like this:</p>
  
  <pre><code>void ResultsFilter()
  {
      if (DropDownList1.SelectedValue.ToString() == "Name")
      {
          ObjectDataSource1.FilterExpression = "Name LIKE '%" + TextBox1.Text + "%' ";
      }
      else if (DropDownList1.SelectedValue.ToString() == "JobTitle")
      {         
          ObjectDataSource1.FilterExpression = "JobTitle LIKE '%" +   TextBox1.Text + "%' ";
      }
  }
  </code></pre>
  
  <p>Ideally I would include the auto complete only if "JobTitle" is selected. Any suggestions on how to achieve this?</p>