title: How to merge values of rows from a multiple column list in c#?
body: <p>I am getting the data from sql server database and in database, I have column say selectedId. If checkbox1 is true, it assigns selectedId as 1. If checkbox2 is true, it assigns selectedId as 2.
  So there are two columns in table. employeeId and SlectedId.<br>
  This is how my table looks in SQL: </p>
  
  <p>Table:  </p>
  
  <pre><code>EmployeeId    SelectedId  
  1234          1  
  1234          2  
  1111          1  
  2222          2  
  </code></pre>
  
  <p>and so on..</p>
  
  <p>So, the idea behind this is, I have a grid, users check the boxes, and it is saved in database the way I mentioned how the table is filled in SQL.
  And once the data is saved, I want to view the saved changes.
  I query my database and store results in a datatable. Then I iterate through each row using 'foreach' and create a multiple column custom list just like below:</p>
  
  <pre><code>List&lt;ResultClass&gt; res = new List&lt;ResultClass&gt;();
  foreach (DataRow row in dt.Rows)
  {
      ResultClass result = new ResultClass ();
      result.employeeId = row["emplid"].ToString().Trim();
  
      if (row["selectedId"] != DBNull.Value)
      {
          if (Convert.ToInt16(row["selectedId"]) == 1)
              result.isCheckbox1 = true;
          if (Convert.ToInt16(row["selectedId"]) == 2)
              result.isCheckbox2 = true;
      }
      else
      {
          result.isCheckbox1 = false;
          result.isCheckbox2 = false;
      }
  
      res.Add(result);      //res is my list          
  }
  
  return res;
  </code></pre>
  
  <p>So, now I have a list like below in memory:</p>
  
  <pre><code>employeeId   checkbox1    Checkbox2  
  1234         true         false  
  1234         false        true  
  </code></pre>
  
  <p>Now I want to merge these rows, so that instead of displaying two separate rows in gridview for employeeId 1234, it should display as below:</p>
  
  <pre><code>employeeId   checkbox1    checkbox2  
  1234         true         true  
  </code></pre>