Autocomplet extender control in ajax (asp.net)?
- by Surya sasidhar
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;
}