title: Display data to View using SqlDataReader in MVC
body: <p>How to display data using Razor view using SqlDataReader in MVC?
  I have tried something like this.</p>
  
  <p>Controller code:-     </p>
  
  <pre><code>public ActionResult UserDetails(DashBoard dash)
      {            
          using (var cn = new SqlConnection(ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString))
          {
              String sql = "SELECT DU.UserRMN, MU.Name, DeptName, MgrID, TLeadID FROM Details_Users DU, Master_Users MU where DU.UserRMN=MU.UserRMN";
              SqlCommand cmd = new SqlCommand(sql, cn);           
              cn.Open();
              SqlDataReader rdr = cmd.ExecuteReader();
              List&lt;DashBoard&gt; model = new List&lt;DashBoard&gt;();
              while(rdr.Read())
              {
                  var details = new DashBoard();
                  details.UserRMN = rdr["UserRMN"].ToString();
                  details.Name = rdr["Name"].ToString();
                  details.DeptID = rdr["DeptID"].ToString();
                  details.MgrID = rdr["MgrID"].ToString();
                  details.TLeadID = rdr["TLeadID"].ToString();
                  model.Add(details);
              }
              return View(model);
          }  
      }
  </code></pre>