title: Display Data from DataTable on ASP.net MVC 2
body: <p>I am creating an asp.net mvc2 project. I wanted to display data from a datatable but when i run the project, it does not display the data i wanted to display.</p>
  
  <p>these are my codes:</p>
  
  <p><b>HomeController.cs</b></p>
  
  <pre><code>    public ActionResult Index()
      {
          connection connect = new connection();
          string query = "SELECT Event_Name FROM tbl_Event WHERE Event_ID=2";
  
          return View(connect.SelectRecord(query));
      }
  </code></pre>
  
  <p><b>Index.aspx</b></p>
  
  <pre><code>    &lt;%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage&lt;System.Data.DataTable&gt;" %&gt;
  
      &lt;asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server"&gt;
          Index
      &lt;/asp:Content&gt;
  
      &lt;asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server"&gt;
  
          &lt;h2&gt;Index&lt;/h2&gt;
          &lt;%Model.Rows[0].ItemArray[0].ToString(); %&gt;
  
      &lt;/asp:Content&gt;
  </code></pre>
  
  <p><b>connection.cs</b></p>
  
  <pre><code>        internal DataTable SelectRecord(string query)
          {
              try
              {
                  OpenConnection();
                  cmd = new SqlCommand(query, conn);
                  adapter = new SqlDataAdapter(cmd);
                  DataTable dt = new DataTable();
                  adapter.Fill(dt);
                  return dt;
              }
              catch (Exception ex)
              {
                  throw ex;
              }
              finally
              {
                  cmd = null;
                  CloseConnection();
              }
  
          }
  </code></pre>
  
  <p><b>I wanted to display this line from Index.aspx</b>  &lt;%Model.Rows[0].ItemArray[0].ToString(); 
  %></p>
  
  <p>I have tried the answer of <b>Kurt Schindler</b> in this link:
  <a href="https://stackoverflow.com/questions/2243898/displaying-standard-datatables-in-mvc">Displaying standard DataTables in MVC</a>
  but it does not specify how to display a specific data from the datatable. Please help me. The reason I use datatable to display data on asp.net views is because I am comfortable using it as my temporary storage of data.</p>