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.

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