+ -
当前位置:首页 → 问答吧 → 求解AutoCompleteExtender不提示的问题

求解AutoCompleteExtender不提示的问题

时间:2011-06-16

来源:互联网

页面源码
C# code

 <td>项目搜索:</td>
       <td><asp:TextBox runat="server" ID="txtProing"></asp:TextBox></td>
       <td>
<asp:AutoCompleteExtender ID="AutoCompleteExtender1" runat="server" 
        TargetControlID="txtProing" MinimumPrefixLength="1" 
    ScriptPath="E:\SVN\TMS\TMS\WebService.asmx" ServiceMethod="GetMyString" 
        CompletionInterval="100">
    </asp:AutoCompleteExtender>



WebService.cs
C# code

using System;
using System.Collections;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Xml.Linq;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Data;

/// <summary>
/// Summary description for WebService
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
[System.Web.Script.Services.ScriptService]
public class WebService : System.Web.Services.WebService {

    public WebService () {

        //Uncomment the following line if using designed components 
        //InitializeComponent(); 
    }

    [WebMethod]
    public string[] GetMyString(string prefixText,int count)
    {
        List<string> ListItem=new List<string>();
        string conn ="server=.;database=TMS;trusted_connection=true";
        string Transql = "select ProjectName from ProjectName where ProjectName like '%" + prefixText + "%'";
        SqlConnection connection=new SqlConnection(conn);
        connection.Open();
        SqlCommand cmd = connection.CreateCommand();
        cmd.CommandText = Transql;
        SqlDataAdapter dataAdapter=new SqlDataAdapter();
        DataTable dataTable=new DataTable();
        dataAdapter.Fill(dataTable);
        for(int i=0;i<dataTable.Rows.Count;i++)
        {
            ListItem.Add(dataTable.Rows[i][1].ToString());
        }
        dataTable.Dispose();
        connection.Close();
        return ListItem.ToArray();
    }
}



我左检查,右检查可是都没发现错误。 但它就是不显示。

作者: chenhongjun0624   发布时间: 2011-06-16

怎么没有人呢  

坐等高手

作者: chenhongjun0624   发布时间: 2011-06-16

谁来 回答一下啊 , 哪怕不对也好啊

作者: chenhongjun0624   发布时间: 2011-06-16