页面: <asp:TextBox ID="txt_place" runat="server" class="inputkprice"></asp:TextBox> <cc1:AutoCompleteExtender ID="txt_place_AutoCompleteExtender" runat="server" DelimiterCharacters="" ServicePath="" ServiceMethod="GetCarCompletionList" UseContextKey="True" MinimumPrefixLength="1" TargetControlID="txt_place"> </cc1:AutoCompleteExtender> 后台: [System.Web.Services.WebMethodAttribute(), System.Web.Script.Services.ScriptMethodAttribute()] public static string[] GetCarCompletionList(string prefixText, int count, string contextKey) { ObjModelDataSource<CAR_加油卡> obj = new ObjModelDataSource<CAR_加油卡>(CAR_加油卡.DBNAME, count, CAR_加油卡.COL_办卡地点 + " like '%" + prefixText + "%'"); string[] str = null; if (obj != null && obj.Count > 0)//obj.DataObjectSource.Tables[0].Rows.Count=obj.Count(但是obj.Count会有问题) { str = new string[obj.GetCount()]; int nN = 0; foreach (CAR_加油卡 item in obj) { str[nN] = item.办卡地点; nN++; } } return str; } /// <summary> /// 司机姓名查询 /// </summary> [System.Web.Services.WebMethodAttribute(), System.Web.Script.Services.ScriptMethodAttribute()] public static string[] GetDriverName(string prefixText, int count, string contextKey) { ObjModelDataSource<CAR_司机资料> obj = new ObjModelDataSource<CAR_司机资料>(CAR_司机资料.DBNAME, count, "司机姓名 like '%" + prefixText + "%'"); string[] str = null; if (obj != null && obj.DataObjectSource.Tables[0].Rows.Count > 0) { str = new string[obj.DataObjectSource.Tables[0].Rows.Count]; int nN = 0; foreach (CAR_司机资料 item in obj) { str[nN] = item.司机姓名; nN++; } } return str; }