title: Get Business Object back from Grid View
body: <p>What exactly is the e.Row.DataItem return.. MSDN says.. <strong>returns An Object that represents the underlying data object to which the GridViewRow object is bound.</strong> </p>
  
  <p>Here is my DataGrid... </p>
  
  <pre><code>    &lt;asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataSourceID="ObjectDataSource1" OnRowDataBound="GridView1_RowDataBound"&gt;
          &lt;Columns&gt;
              &lt;asp:BoundField DataField="PracticeCode" HeaderText="PracticeCode" SortExpression="PracticeCode" /&gt;
              &lt;asp:BoundField DataField="AccountNo" HeaderText="AccountNo" SortExpression="AccountNo" /&gt;
              &lt;asp:BoundField DataField="PatientName" HeaderText="PatientName" SortExpression="PatientName" /&gt;
              &lt;asp:TemplateField HeaderText="Status"&gt;
                  &lt;ItemTemplate&gt;
                      &lt;asp:Label ID="LblStatus" runat="server"&gt;&lt;/asp:Label&gt;
                  &lt;/ItemTemplate&gt;
              &lt;/asp:TemplateField&gt;
          &lt;/Columns&gt;
      &lt;/asp:GridView&gt;
  </code></pre>
  
  <p>And I bind it with my Business Object <strong>List &lt; Patient ></strong>..  In the row DataBound event, I try this...</p>
  
  <pre><code>    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
      {
          Patient p1 = (Patient)e.Row.DataItem;
          Label lbl = e.Row.FindControl("LblStatus") as Label;
  
          if (p1 == null)
          {
              throw new Exception("P1 is null");
          }
  
          if (p1.OpenItems.Count &gt; 0)
          {
              lbl.Text = "Has open Items";
          }
          else
          {
              lbl.Text = "";
          }
      }
  </code></pre>
  
  <p>I get the exception <strong>P1 is null</strong>... Why so...  What am I missing..</p>
  
  <p><strong>Note</strong> : There could be other ways to accomplish this, but I'm looking especially why my p1 is null...  and is there any way to get the <strong>Patient</strong> Object back from GridView after binding.</p>