Autocomplet extender control in ajax (asp.net)?

Posted by Surya sasidhar on Stack Overflow See other posts from Stack Overflow or by Surya sasidhar
Published on 2010-03-06T11:41:34Z Indexed on 2010/03/12 7:37 UTC
Read the original article Hit count: 442

Filed under:

hi, i am using autocomplete extender in my application but it is not working. this is my code..

<form id="form1" runat="server">
<asp:scriptmanager ID="Scriptmanager1" runat="server"></asp:scriptmanager>
    <br />
    <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<div>
    <cc1:AutoCompleteExtender TargetControlID="TextBox1" MinimumPrefixLength="1" 
    ServiceMethod="GetVideoTitles" CompletionSetCount="10" ServicePath="Myservices.asmx" ID="AutoCompleteExtender1" runat="server">
    </cc1:AutoCompleteExtender>
</div>
</form>

this is webservice method

public string[] GetVideoTitles(string prefixText) {

    SqlConnection con = new SqlConnection(@"Data Source=SERVER5\SQLserver2005;Initial Catalog=tpvnew;User ID=xx;Password=525");
    con.Open();
    SqlCommand cmd = new SqlCommand("video_videotitles", con);
    cmd.CommandType = CommandType.StoredProcedure;
    cmd.Parameters.Add("@prefixText", SqlDbType.VarChar, 50);
    cmd.Parameters["@prefixText"].Value = prefixText;

    SqlDataAdapter da = new SqlDataAdapter(cmd);
    DataTable dt = new DataTable(); 
    da.Fill(dt);
    string[] items = new string[dt.Rows.Count];
    int i = 0;
    foreach (DataRow dr in dt.Rows)
    {
        items.SetValue(dr["videotitle"].ToString(), i);
        i++;
    }
    return items;
}

© Stack Overflow or respective owner

Related posts about ASP.NET