I am using Autocomplete using web service. And in my web service I am using LDS.
The problem is that when I am trying this code:
This is my UI code which is calling the webservice in Default.aspx:
<asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
<Services>
<asp:ServiceReference Path ="WebService1.asmx" />
</Services>
</asp:ToolkitScriptManager>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:AutoCompleteExtender ID="TextBox1_AutoCompleteExtender" runat="server"
DelimiterCharacters="" Enabled="True" ServicePath ="WebService1.asmx" ServiceMethod="ReturnEntity" EnableCaching="true" TargetControlID="TextBox1" CompletionSetCount ="1">
</asp:AutoCompleteExtender>
This is my WebService file (webservice1.asmx)
[WebMethod]
public string[] ReturnEntity(string prefixText, int count)
{
List<string> responses = new List<string>();
for (int i = 0; i < count; i++)
responses.Add(prefixText + (char)(i + 65));
return responses.ToArray();
}
Then is it working. However, I am working on this code and it is NOT working…
[WebMethod]
public string[] ReturnEntity(string prefixText)
{
using (DataClasses1DataContext search = new DataClasses1DataContext())
{
string[] fullText = (from n in search.Entities
where n.Name.StartsWith(prefixText)
select n.Name).ToArray();
return fullText;
}
}
When I am trying to run the webservice in the browser itself and passing some parameters then it is showing me these:
<?xml version="1.0" encoding="utf-8" ?>
- <ArrayOfString xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://tempuri.org/">
<string>Starr</string>
<string>Sally Jeans</string>
<string>Steven Kline</string>
<string>Steven Goldberg</string>
</ArrayOfString>
This is not returning any results. I just want to show listings from my table which is Entities, and the column name is ‘Name’.
Cannot figure it out 🙁
Try using StartsWith and pass in a StringComparison
If this is still in the context of call you can use ToLower()