Hi abc,
Refer below sample.
HTML
<table>
<tr>
<td>
<asp:GridView runat="server" ID="GridView1" AutoGenerateColumns="false">
<Columns>
<asp:BoundField DataField="Id" HeaderText="Id" />
</Columns>
</asp:GridView>
</td>
<td>
<asp:GridView runat="server" ID="GridView2" AutoGenerateColumns="false">
<Columns>
<asp:BoundField DataField="Name" HeaderText="Name" />
</Columns>
</asp:GridView>
</td>
<td>
<asp:GridView runat="server" ID="GridView3" AutoGenerateColumns="false">
<Columns>
<asp:BoundField DataField="City" HeaderText="City" />
</Columns>
</asp:GridView>
</td>
</tr>
</table>
Namespaces
C#
using System.Data;
VB.Net
Imports System.Data
Code
C#
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
DataTable dt1 = new DataTable();
dt1.Columns.AddRange(new DataColumn[] { new DataColumn("Id", typeof(int)), new DataColumn("Name", typeof(string)), new DataColumn("City", typeof(string)) });
dt1.Rows.Add(1, "ABC", "Pune");
dt1.Rows.Add(1, "ABC", "mumbai");
dt1.Rows.Add(1, "ABC", "nagpur");
DataView dw = new DataView(dt1);
GridView1.DataSource = dw.ToTable(true, "Id");
GridView1.DataBind();
GridView2.DataSource = dw.ToTable(true, "Name");
GridView2.DataBind();
GridView3.DataSource = dw.ToTable(true, "City");
GridView3.DataBind();
}
}
VB.Net
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
If Not Me.IsPostBack Then
Dim dt1 As DataTable = New DataTable()
dt1.Columns.AddRange(New DataColumn() {New DataColumn("Id", GetType(Integer)), New DataColumn("Name", GetType(String)), New DataColumn("City", GetType(String))})
dt1.Rows.Add(1, "ABC", "Pune")
dt1.Rows.Add(1, "ABC", "mumbai")
dt1.Rows.Add(1, "ABC", "nagpur")
Dim dw As DataView = New DataView(dt1)
GridView1.DataSource = dw.ToTable(True, "Id")
GridView1.DataBind()
GridView2.DataSource = dw.ToTable(True, "Name")
GridView2.DataBind()
GridView3.DataSource = dw.ToTable(True, "City")
GridView3.DataBind()
End If
End Sub
Screenshot