How do I return a conditional list from a web service in ASP.NET?
<p>I'd like to return a list through a web service that takes a string which updates the SQL that supplies the list. I'm not too familiar with building lists, but I already have a list in my class. Again, I'd like to return this list through the web service.</p>

<p>My current list in my table class:</p>

<pre><code>static public List&lt;Skills&gt; GetSkillsList(string like)
{
    List&lt;Skills&gt; thelist = new List&lt;Skills&gt;();

    string sql = "SELECT * FROM Skills WHERE SkillName LIKE '%" + like + "%'";

    SqlDataReader dr = DBUtil.FillDataReader(sql);

    while (dr.Read())
    {
        Skills obj = new Skills();

        obj.skillID = Convert.ToInt32(dr["skillID"].ToString());
        obj.skillName = Convert.ToString(dr["skillName"].ToString());
        obj.skillReviewed = Convert.ToBoolean(dr["skillReviewed"].ToString());
        obj.skillActive = Convert.ToBoolean(dr["skillActive"].ToString());

        thelist.Add(obj);
    }
    return thelist;
}
</code></pre>

<p>Dummy list in the web service:</p>

<pre><code>using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;

[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]

[System.Web.Script.Services.ScriptService]
public class AutoComplete : System.Web.Services.WebService {

[WebMethod]
public IList&lt;string&gt; GetSkills(string contains)
{

    IList&lt;string&gt; output = new List&lt;string&gt;();
    output.Add("Apple");
    output.Add("Ajax");
    output.Add("Alpha");
    output.Add("Alphred");
    return output;    
}
}
</code></pre>

<p>I'd like to return the Name and the ID fields in the web service list.</p>

<p>I would think it would be something like:</p>

<pre><code>    [WebMethod]
public IList&lt;string&gt; SkillsList(string like)
{
    IList&lt;string&gt; output = new List&lt;string&gt;();

    output = Skills.GetSkillsList(like);

    return output;
}
</code></pre>

<p>but I know this is incorrect.</p>

<p>Any help is appreciated!</p>
