title: Selecting DataRow using Linq in c#
body: <p>How can I make this to shorter one using Linq?</p>
  
  <pre><code>int id = 0;
  foreach (DataRow dr in tableClientTableAdapter1.GetData())
  {
       if (dr[0].ToString() == txtClientName.Text)
        {
            id = Convert.ToInt16(dr[1]);
            break;
        }
  }
  </code></pre>
  
  <p>I tried using this </p>
  
  <pre><code>var a = tableClientTableAdapter1.GetData().Cast&lt;DataRow&gt;().Where(cName =&gt; cName[0].ToString() == txtClientName.Text);
  MessageBox.Show(a[1].ToString());
  </code></pre>
  
  <p>But I got this error:</p>
  
  <blockquote>
    <p>Error 1   Cannot apply indexing with [] to an expression of type 'System.Data.EnumerableRowCollection'   C:\Users\vrynxzent@yahoo.com\Desktop[Final][GlobalTek] Monitoring System[GlobalTek] Monitoring System\xfrmProjectAwarding.cs  89  37  [GlobalTek] Monitoring System</p>
  </blockquote>
  
  <p>Any help!!</p>