ASPForums.Net RSS Feedhttp://www.aspforums.net/Handlers/RSS.ashxLatest additions to the content that appears on ASPForums.Net(c) 2019 www.aspforums.com. All rights reserved.Split DataTable into multiple Tables using C# and VB.Net in Windows Application<p>Hi <a class="username" rel="satabeach"> satabeach</a></p> <p>Refer below sample.</p> <p><span style="text-decoration: underline;"><strong>Code</strong></span></p> <p><strong>C#</strong></p> <pre class="brush: csharp">private void Form1_Load(object sender, EventArgs e) { &nbsp;&nbsp;&nbsp; DataTable dt = new DataTable(); &nbsp;&nbsp;&nbsp; dt.Columns.AddRange(new DataColumn[] { new DataColumn(&#34;Id&#34;, typeof(int)), new DataColumn(&#34;Name&#34;, typeof(string)) }); &nbsp;&nbsp;&nbsp; dt.Rows.Add(1, &#34;Mudassar Khan&#34;); &nbsp;&nbsp;&nbsp; dt.Rows.Add(2, &#34;John Hammond&#34;); &nbsp;&nbsp;&nbsp; dt.Rows.Add(3, &#34;Suzanne Mathews&#34;); &nbsp;&nbsp;&nbsp; dt.Rows.Add(4, &#34;Robert Schidner&#34;); &nbsp;&nbsp;&nbsp; dt.Rows.Add(5, &#34;Mudassar Khan&#34;); &nbsp;&nbsp;&nbsp; dt.Rows.Add(6, &#34;John Hammond&#34;); &nbsp;&nbsp;&nbsp; dt.Rows.Add(7, &#34;Suzanne Mathews&#34;); &nbsp;&nbsp;&nbsp; dt.Rows.Add(8, &#34;Robert Schidner&#34;); &nbsp;&nbsp;&nbsp; dataGridView1.DataSource = dt.Rows.Cast&lt;DataRow&gt;().Take(4).CopyToDataTable(); &nbsp;&nbsp;&nbsp; dataGridView2.DataSource = dt.Rows.Cast&lt;DataRow&gt;().Skip(4).CopyToDataTable(); }</pre> <p><strong>VB.Net</strong></p> <pre class="brush: vb">Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load &nbsp;&nbsp;&nbsp; Dim dt As DataTable = New DataTable() &nbsp;&nbsp;&nbsp; dt.Columns.AddRange(New DataColumn() {New DataColumn("Id", GetType(Integer)), New DataColumn("Name", GetType(String))}) &nbsp;&nbsp;&nbsp; dt.Rows.Add(1, "Mudassar Khan") &nbsp;&nbsp;&nbsp; dt.Rows.Add(2, "John Hammond") &nbsp;&nbsp;&nbsp; dt.Rows.Add(3, "Suzanne Mathews") &nbsp;&nbsp;&nbsp; dt.Rows.Add(4, "Robert Schidner") &nbsp;&nbsp;&nbsp; dt.Rows.Add(5, "Mudassar Khan") &nbsp;&nbsp;&nbsp; dt.Rows.Add(6, "John Hammond") &nbsp;&nbsp;&nbsp; dt.Rows.Add(7, "Suzanne Mathews") &nbsp;&nbsp;&nbsp; dt.Rows.Add(8, "Robert Schidner") &nbsp;&nbsp;&nbsp; dataGridView1.DataSource = dt.Rows.Cast(Of DataRow)().Take(4).CopyToDataTable() &nbsp;&nbsp;&nbsp; dataGridView2.DataSource = dt.Rows.Cast(Of DataRow)().Skip(4).CopyToDataTable() End Sub</pre> <p><span style="text-decoration: underline;"><strong>Screenshot</strong></span></p> <p><span style="text-decoration: underline;"><strong><img src="https://i.imgur.com/wSyjyEC.jpg" alt="" width="512" height="183" /></strong></span></p>https://www.aspforums.net:443/Threads/197431/Split-DataTable-into-multiple-Tables-using-C-and-VBNet-in-Windows-Application/https://www.aspforums.net:443/Threads/197431/Split-DataTable-into-multiple-Tables-using-C-and-VBNet-in-Windows-Application/Tue, 14 May 2019 03:43:38 GMT