Friday, April 15, 2016

  • Conevert Datatable to Object List C# ASP.Net / ASP MVC



      DataTable dt = new DataTable();
      SqlDataAdapter da = new SqlDataAdapter(command);
      da.Fill(dt);


                var list = dt.AsEnumerable()
    .Skip(1)
    .Select(dr =>
            new StudentListResponse
            {
                id = dr["PKStudentID"].ToString(),
                name = dr["StudentName"].ToString(),
                profile_pic = dr["PhotoURL"].ToString()
            }
            ).ToList();



    Here dt is the DataTable Holds data.
    And StudentListResponse object list is created.


  • 1 comments:

    1. Nice blog. A program is written on how to Convert Data table to Object List C# ASP.Net / ASP MVC. Really useful for asp.net user and developer. Developing a website for personal or professional use is a very good idea and hosting is necessary for a website. So You can choose the best Asp.net hosting plan.

      ReplyDelete

    Copyright @ 2013 Code Snippets.