Selecting Multiple Rows from DataTable using Linq
<p>I have a <code>DataTable</code> that has these columns:</p>

<pre><code>AlertEmail , ClosingDate , OpeningDate , LocationTitle , JobTitle
</code></pre>

<p>I want to Search this <code>DataTable</code> and find Records for each AlertEmail. I do this but MailInfo returned <code>NULL</code>.</p>

<pre><code>DataTable dt = amail.GetAllJobAlertForSend();

var AllEmail = dt.AsEnumerable()
                 .Select(row =&gt; new {attribute1_name = row.Field&lt;string&gt;("AlertEmail") }).Distinct();

foreach (var mail in AllEmail)
{
    var MailInfo = from p in dt.AsEnumerable()
                   where p.Field&lt;string&gt;("AlertEmail").Trim() == mail.ToString()
                   select new
                   {
                       ClosingDate = p.Field&lt;DateTime&gt;("ClosingDate"),
                       OpeningDate = p.Field&lt;DateTime&gt;("OpeningDate"),
                       LocationTitle = p.Field&lt;string&gt;("LocationTitle"),
                       JobTitle = p.Field&lt;string&gt;("JobTitle")
                   };

    foreach (var info in MailInfo)
    {
        Response.Write(string.Format("{0}", info.ClosingDate));
    }
}
</code></pre>

<p>What was wrong in my code?</p>