asp.NetAutoCompleteExtenderの簡単な例コード

2151 ワード

 
  



AutoComplete.asmx
 
  


AutoComplete.cs
 
  
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Data;

///
///add by ahuinan
///

[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
// ASP.NET AJAX Web , 。
[System.Web.Script.Services.ScriptService]
public class AutoComplete : System.Web.Services.WebService
{


public AutoComplete()
{

// ,
//InitializeComponent();
}

[WebMethod]
public string HelloWorld()
{
return "Hello World";
}


//
[WebMethod]
public string[] GetScenic(string prefixText,int count)
{

ET_ERP.BLL.ERP_ScenicArea b_ScenicArea = new ET_ERP.BLL.ERP_ScenicArea();
string strWhere = " SA_Name like '" + prefixText + "%' AND SA_IsDel = 0";

DataSet ds = b_ScenicArea.Select(" top "+count+" SA_Name", strWhere);

count = ds.Tables[0].Rows.Count;

string[] array = new string[count];
for (int i = 0; i < count; i++)
{
array[i] = ds.Tables[0].Rows[i]["SA_Name"].ToString();
}

return array;
}
}