title: Consuming .Net Webservice list function
body: <p>I am trying to return a list from a web method. 
  I am trying to consume the service, I am having problem.
  I want to show the values in 3 different labels, I dont know how can I do that.</p>
  
  <p>Given the following web method:</p>
  
  <pre><code>    [WebMethod]
      public List&lt;Employee&gt; empWeb(int Id)
      {
          Employee emp = new Employee();
          List&lt;Employee&gt; emplist = new List&lt;Employee&gt;();
  
          con.Open();
          SqlCommand cmd = new SqlCommand("select Id,FirstName,Salary from Emp where Id='" + Id + "' ", con);
          SqlDataReader dr;
          dr = cmd.ExecuteReader();
          while (dr.Read())
          {
  
              emp.Id = Convert.ToInt32(dr["Id"]);
              emp.Name = dr["FirstName"].ToString();
              emp.Salary = Convert.ToInt32(dr["Salary"]);
  
  
          }
  
          con.Close();
          emplist.Add(emp);
          return emplist;
      }
  </code></pre>
  
  <p>Employee Class</p>
  
  <pre><code>    public class Employee
  {
      int iId, isalary;
      string sname;
      public int Id
      {
          get { return iId; }
          set { iId = value; }
      }
      public string Name
      {
          get { return sname; }
          set { sname = value; }
      }
      public int Salary
      {
          get { return isalary; }
          set { isalary = value; }
      }
  }
  </code></pre>
  
  <p>Now I am trying to consume in my aspx page. Code of my aspx page is as follows:-</p>
  
  <pre><code>    public void GetWebEmp()
  {
      localhost.Service1 obj = new localhost.Service1();
      var lstwebemp = obj.empWeb(1);
  
  }
  </code></pre>
  
  <p>In this function I want to show values like</p>
  
  <pre><code>Label1.Text=Emp.Id
  
  Label2.Text=Emp.Name
  
  Label3.Text=Emp.Salary
  </code></pre>
  
  <p>but it is showing all values in <code>lstwebemp</code> 
  Please Help.</p>