title: Infragistics WebDataGrid get value from a selected row by column name: VB.net to C# conversion
body: <p>I'm in the process of converting a website with codebehind in VB.NET to C#. The only real problem I'm having is getting data from an Infragistics WebDataGrid row by column name in the <code>RowSelectionChanged</code> event.</p>
  
  <p>Example VB.NET code:</p>
  
  <pre><code>If Me.WebDataGrid1.Behaviors.Selection.SelectedRows(0).DataItem("Status").ToString &lt;&gt; "Released" Then
          '"Status" is the column name
  End If
  </code></pre>
  
  <p>I figured changing it to this would pretty much do it, but to no avail.</p>
  
  <pre><code>if (this.WebDataGrid1.Behaviors.Selection.SelectedRows[0].DataItem["Status"].ToString() != "Released") { 
          //do stuff
  }
  </code></pre>
  
  <p>Specifically the error I get is, <code>Cannot apply indexing with [] to an expression of type 'object'</code>, which I'm pretty positive is referring to the <code>DataItem["Status"]</code> part.</p>
  
  <p>How do I go about getting the value from the selected row for a column specified by name?</p>
  
  <p>UPDATE: I found a solution, which is in the answers below, but it could probably be done better. I'll gladly accept a different answer if a better one comes along.</p>