hi rrmisinfo,
You need to format the query to display the column Particulars.
Please refer below example.
Database
For this example I have used of Northwind database that you can download using the link given below.
Download Northwind Database
HTML
<asp:PlaceHolder ID="PlaceHolder1" runat="server" />
Namespaces
C#
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Text;
VB.Net
Imports System.Data
Imports System.Data.SqlClient
Imports System.Configuration
Imports System.Text
Code
C#
protected void Page_Load(object sender, EventArgs e)
{
DataTable inputData = new DataTable();
string constr = ConfigurationManager.ConnectionStrings["constr"].ConnectionString;
string query = "SELECT TOP 5 OrderID, OrderDate, EmployeeID, CustomerID, '<b>' + ShipName + '</b><br />' + ShipCity 'Details', Freight FROM [Orders]";
using (SqlConnection con = new SqlConnection(constr))
{
using (SqlDataAdapter sda = new SqlDataAdapter(query, con))
{
sda.Fill(inputData);
}
}
StringBuilder Sb = new StringBuilder();
Sb.Append("<table class='table'>");
Sb.Append("<thead>");
Sb.Append("<tr>");
foreach (DataColumn columnName in inputData.Columns)
{
Sb.Append("<th>" + columnName.ColumnName + "</th>");
}
Sb.Append("</tr>");
Sb.Append("</thead>");
Sb.Append("<tbody>");
foreach (DataRow row in inputData.Rows)
{
Sb.Append("<tr>");
foreach (DataColumn columnName in inputData.Columns)
{
Sb.Append("<td>" + row[columnName.ColumnName].ToString() + "</td>");
}
Sb.Append("</tr>");
}
Sb.Append("</tbody>");
Sb.Append("</table>");
PlaceHolder1.Controls.Add(new Literal() { Text = Sb.ToString() });
}
VB.Net
Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
Dim inputData As New DataTable()
Dim constr As String = ConfigurationManager.ConnectionStrings("constr").ConnectionString
Dim query As String = "SELECT TOP 5 OrderID, OrderDate, EmployeeID, CustomerID, '<b>' + ShipName + '</b><br />' + ShipCity 'Details', Freight FROM [Orders]"
Using con As SqlConnection = New SqlConnection(constr)
Using sda As SqlDataAdapter = New SqlDataAdapter(query, con)
sda.Fill(inputData)
End Using
End Using
Dim Sb As StringBuilder = New StringBuilder
' Create the data table
Sb.Append("<table class='table'>")
Sb.Append("<thead>")
Sb.Append("<tr>")
For Each columnName As DataColumn In inputData.Columns
Sb.Append("<th>" & columnName.ColumnName & "</th>")
Next
Sb.Append("</tr>")
Sb.Append("</thead>")
Sb.Append("<tbody>")
For Each row As DataRow In inputData.Rows
Sb.Append("<tr>")
For Each columnName As DataColumn In inputData.Columns
Sb.Append("<td>" & row(columnName.ColumnName).ToString() & "</td>")
Next
Sb.Append("</tr>")
Next
Sb.Append("</tbody>")
Sb.Append("</table>")
PlaceHolder1.Controls.Add(New Literal() With {.Text = Sb.ToString()})
End Sub
Screenshot