Sandy Surwase

Sandy Surwase

  • NA
  • 287
  • 30.5k

i try autocomplete textbox but somthing is wrong plz help me

Oct 22 2012 6:44 AM
using System;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;

public partial class autocompletdemo : System.Web.UI.Page
{
  protected void Page_Load(object sender, EventArgs e)
  {

  }

  [System.Web.Services.WebMethodAttribute(), System.Web.Script.Services.ScriptMethodAttribute()]
  public static string[] GetCompletionList(string prefixText, int count, string contextKey)
  {
  string cs = ConfigurationManager.ConnectionStrings["NorthwindCS"].ConnectionString;
  SqlConnection cn = new SqlConnection(cs);
  SqlDataAdapter da=new SqlDataAdapter("select ProductName from Products",cn);
  DataSet ds = new DataSet();
  da.Fill(ds, "Products");
  DataView dv = new DataView(ds.Tables[0]);
  dv.RowFilter = string.Format("ProductName like '{0}%'",prefixText);
  int rcount, size;
  rcount = dv.Count;
  if (rcount >= count)
  size = count;
  else
  size = rcount;
  string[] Pnames = new string[size];
  for (int i = 0; i < size; i++ )
  {
  Pnames[i] = dv.[i]["PoductName"].toString();
  }
  return Pnames;

   
  }
}
there is error in marked line plz help mi out

Answers (3)