Guruji Point - Code You Want To Write

  • Home
  • Asp.Net
  • WCF
  • SQL
  • Type Script
  • AngularJS
  • Tech News
  • Blog
  • Earn Online

Sunday, 27 August 2017

Convert DataSet To List Or GenericList Using Foreach Loop In C#

 asp.net, Asp.Net C#, DataSet, DataSet to genericList, DataSet to List, guruji point, Gurujipoint     No comments   

Introduction
In this article we will learn how to convert dataset to list or convert DataSet to List of collection o generic list in c#. Convert DataSet into List using LINQ. 

Many times we face this condition when we need to convert our DatSet data into a List of Collection. So here you can find the solution of this Using forach.


Suppose i have a DataSet data looks like give below image


Read here Convert DataList To List Using LINQ - C#

Employee objEmp = new Employee();
List<Employee> empList = new List<Employee>();
foreach (DataRow dr in ds.Tables[0].Rows)
{

  empList.Add(new Employee{
            EmpID = Convert.ToInt32(dr["EmpID"]),
            EmpName = Convert.ToString(dr["EmpName"])
});

}

Here Employee is entity and EmpId and EmpName are its properties which i want to retrieve in List data. 
You may also interested Difference between array and ArrayList with example. 



  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg
Email ThisBlogThis!Share to TwitterShare to Facebook
Newer Post Older Post Home

0 comments:

Post a Comment

Facebook Updates

Guruji Point

Categories

comma seperated string in sql Comman table Expression in SQL Dynamic Grid Row IQueryable in c# Learn AngularJS row_number() and dense_rank() salary table structure. Scope_Identity() Use of indexes while loop in sql why do we need cursor why tuple used

About Us

This blog is about the Programming ,Tech News and some intresting facts related Contents. Here you can find fundamental and expert level topic of programming languages very practically related to C# , Asp.Net ,Sql-Server, JavaScript, Jquery, WebServices And also Web-Api, WCF ,WPF, Angular Js.

Contact Us

Email Us - gurujipoints@gmail.com
Contact- 8077657477

Reach Us

Copyright © Guruji Point - Code You Want To Write