Skip to content
InfinityKnow

InfinityKnow

Infinity Knowledge (IK) : Technology, Articles, Topics, Facts or many More.

  • Home
  • Education
    • yttags
    • Make Money
    • Jobs
    • Programming
      • Technology
      • Web Design
      • WEB HOSTING
      • Interview
  • Entertainment
    • pakainfo
    • Sports
    • Tips and Tricks
      • Law
      • Photography
      • Travel
  • Health
    • Insurance
    • Lifestyle
      • Clothing
      • Fashion
      • Food
  • News
    • Insurance
      • Auto Car Insurance
      • Business Insurance
    • Donate
    • California
  • News
    • Political
  • Home Improvement
  • Trading
    • Marketing
    • Top Tranding
    • Business
    • Real Estate
  • Full Form
  • Contact Us
  • Laravel Create Migration to Store Sessions in The Database
    Laravel Create Migration to Store Sessions in The Database Technology
  • Vuejs Simple Navigation Menu vue router-link params
    Vuejs Simple Navigation Menu vue router-link params Technology
  • PHP Laravel CRUD Application Tutorial for Beginners Technology
  • vuejs Table Searching Sorting and Pagination Technology
  • SharePoint Migration Services
    Why SharePoint Migration Services is Important for Businesses ? Articles
  • How To Start A Paper Bag Business? Articles
  • Angular Resource Encode and Decode URL Technology
  • pda full form – pda Kya Hai, Meaning and Abbreviation – What is the full form of pda? full form

convert generic list to datatable in Asp.Net C#,VB

Posted on May 24, 2019 By admin No Comments on convert generic list to datatable in Asp.Net C#,VB

convert generic list to datatable in Asp.Net C#,VB

Today, We want to share with you convert generic list to datatable in Asp.Net C#,VB.
In this post we will show you Converting Generic List into DataTable, hear for c# – How to convert a list into data table we will give you demo and example for implement.
In this post, we will learn about Converting Generic List into DataTable with an example.

Introduction

In this post, I will explain how you can convert generic list to DataTable. In the below example I am having a list of colors that I will convert to DataTable.

Example : Convert generic list to DataTable

[php]
private void FillData()
{
List _ColorList = new List(); // List to be converted into DataTable
_ColorList.Add(“Red”);
_ColorList.Add(“White”);
_ColorList.Add(“Black”);
_ColorList.Add(“Green”);
_ColorList.Add(“Blue”);
DataTable _ResultDataTable = ConvertListToDataTable(_ColorList);
}

READ :  AngularJs HTML DOM Manipulation With Example

public static DataTable ConvertListToDataTable(IList p_ColorList)
{
DataTable _DataTable = new DataTable();
if (typeof(T).IsValueType || typeof(T).Equals(typeof(string)))
{
DataColumn _DataColumn = new DataColumn(“ColorList”);
_DataTable.Columns.Add(_DataColumn);

foreach (T item in p_ColorList)
{
DataRow dr = _DataTable.NewRow();
dr[0] = item;
_DataTable.Rows.Add(dr);
}
}
else
{
PropertyInfo[] _PropertyInfo = typeof(T).GetProperties();
foreach (PropertyInfo pi in _PropertyInfo)
{
DataColumn dc = new DataColumn(pi.Name, pi.PropertyType);
_DataTable.Columns.Add(dc);
}

for (int item = 0; item < p_ColorList.Count(); item++)
{
DataRow _DataRow = _DataTable.NewRow();
for (int property = 0; property < _PropertyInfo.Length; property++)
{
_DataRow[property] = _PropertyInfo[property].GetValue(p_ColorList[item], null);
}
_DataTable.Rows.Add(_DataRow);
}
}
_DataTable.AcceptChanges();
return _DataTable;
}
[/php]

Read :

  • Technology
  • Google Adsense
  • Articles

Summary

You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about Converting Generic List into DataTable.
I would like to have feedback on my Infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

READ :  Dropbox API - Laravel Oauth Dropbox File Upload Steps

We hope you get an idea about Converting Generic List into DataTable
We would like to have feedback on my Information blog .
Your valuable any feedback, Good question, Inspirational Quotes, or Motivational comments about this article are always welcome.
If you liked this post, Please don’t forget to share this as Well as Like FaceBook Page.

We hope This Post can help you…….Good Luck!.

Searches related to : Converting Generic List into DataTable

  • Converting Generic List into DataTable
  • List to Datatable Converter Using C#
  • Convert Generic List to Data Table
  • How to convert generic list to datatable
  • Convert a Generic List to a Datatable
  • C# Convert List to DataTable (DataGridView)
  • How to convert generic list to datatable in Asp.Net C#,VB
READ :  PHP classes constructor and destructor Example

Related posts:

  1. Vuejs Simple Navigation Menu vue router-link params
  2. Convert Serialize List Object to JSON String in C# ASP.NET
  3. vuejs toggle class – vue js v-class – Dynamic Components in Vuejs
  4. Vuejs Simple Tooltip Plugin v-tooltip Example
Technology, Asp.Net Tags:convert list to dataset in asp net, convert list to dataset in mvc, convert list to datatable in c# extension methods, convert list to datatable in c# using linq, convert list to datatable in c# without looping, convert nested list to datatable in c#, how to convert model to datatable in c#, vb.net list to datatable

Post navigation

Previous Post: Free POS Software Canada point of sale systems
Next Post: Vue js array Updating – VueJS update object properties

Related Posts

  • VueJS Toggle class hide-show on click Event
    VueJS Toggle class hide-show on click Event Technology
  • Laravel Create Database Migration and Model
    Laravel Create Database Migration and Model Technology
  • angularjs filter orderby descending,ng-repeat reverse object,ng-repeat orderby object property,angularjs filter orderby in controller,ng-repeat orderby key,angular orderby pipe,angularjs sort array in controller,sorting filter in angular
    Angular ng-repeat reverse Example – reverse filter Technology
  • Get url parameter using angular js
    Get url parameter using angular js Technology
  • Vuejs Computed properties – vue watch computed property Examples
    Vuejs Computed properties – vue watch computed property Examples Technology
  • VueJS Installation and Configuration – VueJS Environment Setup
    VueJS Installation and Configuration – VueJS Environment Setup Technology

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Categories

  • Account web hosting (1)
  • AngularJs (277)
  • Articles (143)
  • Asp.Net (49)
  • Astrology (2)
  • Attorney (7)
  • Auto Car Insurance (4)
  • Biography (2)
  • Business (9)
  • Business Insurance (3)
  • California (4)
  • Choose the web hosting (1)
  • Clothing (6)
  • cloud (8)
  • Cloud data storage (2)
  • Credit (1)
  • Dedicated hosting server web (1)
  • Dedicated server web hosting (1)
  • Dedicated web hosting (1)
  • Degree (11)
  • Design (9)
  • Differences shared hosting (1)
  • Donate (2)
  • Education (37)
  • Energy web hosting (1)
  • Entertainment (6)
  • Facts (12)
  • Fashion (3)
  • Finance (3)
  • Food (5)
  • full form (90)
  • Google Adsense (22)
  • Health (21)
  • Home Improvement (5)
  • Insurance (7)
  • Interview (2)
  • Jobs (6)
  • jquery (2)
  • jQuery (2)
  • Laravel (164)
  • Lawyer (4)
  • Lifestyle (6)
  • Loans (6)
  • Make Money (31)
  • Managed dedicated server (1)
  • Managed hosting solution (1)
  • Managed servers (1)
  • Marketing (8)
  • Mortgage (2)
  • Movies (21)
  • MySQL (180)
  • News (5)
  • Photography (1)
  • PHP (250)
  • Programming (18)
  • Quotes (75)
  • Real Estate (2)
  • SEO (9)
  • Shared web hosting (1)
  • Shayari (67)
  • Sports (5)
  • Status (34)
  • Stories (45)
  • suvichar (8)
  • Tech (3)
  • Technology (675)
  • Tips and Tricks (43)
  • Top Tranding (36)
  • Trading (28)
  • Travel (12)
  • Uncategorized (8)
  • VueJs (179)
  • Web Design (2)
  • WEB HOSTING (1)
  • Web hosting company (1)
  • Web hosting really (1)
  • Web hosting windows (1)
  • Which website hosting (1)
  • Wishes (13)
  • wordpress (15)

Categories

AngularJs (277) Articles (143) Asp.Net (49) Attorney (7) Business (9) Clothing (6) cloud (8) Degree (11) Design (9) Education (37) Entertainment (6) Facts (12) Food (5) full form (90) Google Adsense (22) Health (21) Home Improvement (5) Insurance (7) Jobs (6) Laravel (164) Lifestyle (6) Loans (6) Make Money (31) Marketing (8) Movies (21) MySQL (180) News (5) PHP (250) Programming (18) Quotes (75) SEO (9) Shayari (67) Sports (5) Status (34) Stories (45) suvichar (8) Technology (675) Tips and Tricks (43) Top Tranding (36) Trading (28) Travel (12) Uncategorized (8) VueJs (179) Wishes (13) wordpress (15)
  • AngularJS Tutorial RESTful JSON Parsing
    AngularJS Tutorial RESTful JSON Parsing Technology
  • Tips For Beginner Day Trader In Cryptocurrencies Articles
  • How to get last record of table in Laravel 6? Technology
  • Angular Routing and Views Templating Tutorial Technology
  • Best National Public Colleges & Universities in the United States
    Best National Public Colleges & Universities in the United States Education
  • Vuejs Dynamic Displaying Lists v-for directive
    Vuejs Dynamic Displaying Lists v-for directive Technology
  • C# Armstrong Number Tutorial with Examples Technology
  • Get last query executed in Laravel 5.8
    Get last query executed in Laravel 5.8 MySQL

Copyright © 2022 InfinityKnow.

Powered by PressBook News WordPress theme