title: display data from database in datagridview with entity framework in c#
body: <p>I'm using Empty Web Application as my host and i have different classes, such as users in it.</p>
  
  <p>I also have a client (Windows Forms app). <strong>Please notice this is Entity framework database!</strong></p>
  
  <p>Ok here's the thing. I want to display each and every single data in datagridview (seperate columns for ID, Name, etc...)</p>
  
  <p>In my Empty Web app, i have Webservice where i have the code for displaying users.</p>
  
  <p><strong>Here is the code</strong></p>
  
  <pre><code>[WebMethod]
      public List&lt;string&gt; getUsers()
      {
          List&lt;string&gt; userList = new List&lt;string&gt;();
          using (var db = new Database())
          {
              var query = from x in db.userList
                              orderby x.UserID
                              select x;
  
              foreach (var user in query)
              {
                  userList.Add(user.userID + user.Name); //also some other information, but doesnt really matter here
              }
          }
          return userList;
      }
  </code></pre>
  
  <p>Ok, off to Windows Forms App (client).</p>
  
  <p>Now i need to display this data in datagridview (in seperate columns), meaning:</p>
  
  <p>userID gets displayed in ID colument
  Name gets displayed in Name column</p>
  
  <p>Here is where problem occurres. All the data gets displayed in each column. <strong>USERID + NAME GETS DISPLAYED IN ID COLUMN</strong></p>
  
  <p><strong>My code</strong></p>
  
  <pre><code>ServiceReference1.mojWebServiceSoapClient client = new ServiceReference1.mojWebServiceSoapClient();
  
          var userL = client.pridobiUporabnike();
  
          foreach (string user in userL)
          {
              string[] row = new string[6];
              row[0] = user;
              row[1] = user;
              row[2] = user;
              row[3] = user;
              row[4] = user;
              row[5] = user;               
              dataGridView1.Rows.Add(row);
          }
  </code></pre>
  
  <p>You're going to say "ofcourse it displays same data, when u have "user" everywhere. I know...i tried many things, but somehow i just can't make it work.</p>
  
  <p>I think code should look something like row[0] = user.UserID;
  row<a href="https://i.stack.imgur.com/jEkhQ.jpg" rel="nofollow noreferrer">1</a> = user.Name;</p>
  
  <p><strong>Can you please guys help me fix this, i would really appreaciate it</strong></p>
  
  <p>Thanks a lot to any1 who gives input.</p>
  
  <p>Im also including the results of running program.</p>
  
  <p><img src="https://i.stack.imgur.com/jEkhQ.jpg" alt="enter image description here"></p>