Hi rakeshkuma,
Please refer below sample.
HTML
<asp:Label runat="server" ID="lblData"></asp:Label>
Namespace
C#
using System.Data;
VB.Net
Imports System.Data
Code
C#
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
DataTable dt;
dt = new DataTable("TableName");
DataColumn column1 = new DataColumn("Column1");
column1.DataType = System.Type.GetType("System.String");
DataColumn column2 = new DataColumn("Column2");
column2.DataType = System.Type.GetType("System.String");
dt.Columns.Add(column1);
dt.Columns.Add(column2);
DataRow Row1;
Row1 = dt.NewRow();
DataRow Row2;
Row2 = dt.NewRow();
DataRow Row3;
Row3 = dt.NewRow();
Row1["Column1"] = "Ismail";
Row1["Column2"] = 100;
Row2["Column1"] = "Mohammed";
Row2["Column2"] = 200;
Row3["Column1"] = "Siraj";
Row3["Column2"] = 300;
dt.Rows.Add(Row1);
dt.Rows.Add(Row2);
dt.Rows.Add(Row3);
string rowCount = dt.Rows.Count.ToString();
string data = "<div class='row'>";
foreach (DataRow row in dt.Rows)
{
string table = "<div class='col-sm-2'>";
table += " <div class='form-group'>";
table += " <div class='row'>";
table += " " + row["Column1"].ToString() + "";
table += " </div>";
table += " </div>";
table += "</div>";
table += " <div class='form-group'>";
table += " <div class='row'>";
table += " " + row["Column2"].ToString() + "";
table += " </div>";
table += " </div>";
table += "</div>";
data += table;
}
data += "</div>";
lblData.Text = data;
}
}
VB.Net
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
If Not IsPostBack Then
Dim dt As DataTable
dt = New DataTable("TableName")
Dim column1 As DataColumn = New DataColumn("Column1")
column1.DataType = System.Type.[GetType]("System.String")
Dim column2 As DataColumn = New DataColumn("Column2")
column2.DataType = System.Type.[GetType]("System.String")
dt.Columns.Add(column1)
dt.Columns.Add(column2)
Dim Row1 As DataRow
Row1 = dt.NewRow()
Dim Row2 As DataRow
Row2 = dt.NewRow()
Dim Row3 As DataRow
Row3 = dt.NewRow()
Row1("Column1") = "Ismail"
Row1("Column2") = 100
Row2("Column1") = "Mohammed"
Row2("Column2") = 200
Row3("Column1") = "Siraj"
Row3("Column2") = 300
dt.Rows.Add(Row1)
dt.Rows.Add(Row2)
dt.Rows.Add(Row3)
Dim rowCount As String = dt.Rows.Count.ToString()
Dim data As String = "<div class='row'>"
For Each row As DataRow In dt.Rows
Dim table As String = "<div class='col-sm-2'>"
table += " <div class='form-group'>"
table += " <div class='row'>"
table += " " & row("Column1").ToString() & ""
table += " </div>"
table += " </div>"
table += "</div>"
table += " <div class='form-group'>"
table += " <div class='row'>"
table += " " & row("Column2").ToString() & ""
table += " </div>"
table += " </div>"
table += "</div>"
data += table
Next
data += "</div>"
lblData.Text = data
End If
End Sub
Screenshot