Hi satabeach,
Refer below sample.
HTML
<asp:GridView ID="gvCustomer" runat="server">
</asp:GridView>
Namespaces
C#
using System.Data;
VB.Net
Imports System.Data
Code
C#
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
DataTable dt = new DataTable();
dt.Columns.AddRange(new DataColumn[] { new DataColumn("ID")});
dt.Rows.Add("1555");
dt.Rows.Add("1556");
dt.Rows.Add("1557");
var list = dt.AsEnumerable().Select(r => r["ID"].ToString());
string value = string.Join(",", list);
dt.Rows.Clear();
dt.Rows.Add(value);
gvCustomer.DataSource = dt;
gvCustomer.DataBind();
}
}
VB.Net
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
If Not Me.IsPostBack Then
Dim dt As DataTable = New DataTable()
dt.Columns.AddRange(New DataColumn() {New DataColumn("ID")})
dt.Rows.Add("1555")
dt.Rows.Add("1556")
dt.Rows.Add("1557")
Dim list = dt.AsEnumerable().[Select](Function(r) r("ID").ToString())
Dim value As String = String.Join(",", list)
dt.Rows.Clear()
dt.Rows.Add(value)
gvCustomer.DataSource = dt
gvCustomer.DataBind()
End If
End Sub
Output
ID
1555,1556,1557