Hi rajeesh,
Check this example. Now please take its reference and correct your code.
You need to write the DataList binding code from database instead of temporary DataTable.
HTML
<asp:DataList ID="dlUrls" runat="server" RepeatColumns="1" CellSpacing="3" RepeatLayout="Table">
<ItemTemplate>
<table class="table">
<tr>
<td>
<asp:Label Text='<%# Eval("Name") %>' runat="server" />
</td>
<td>
<asp:LinkButton Text='<%# Eval("Name") %>' runat="server" PostBackUrl='<%# Eval("Url") %>' />
</td>
</tr>
</table>
</ItemTemplate>
</asp:DataList>
Code
C#
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
System.Data.DataTable dt = new System.Data.DataTable();
dt.Columns.AddRange(new System.Data.DataColumn[] {
new System.Data.DataColumn("Name"),
new System.Data.DataColumn("Url") });
dt.Rows.Add("aspforums", "https://www.aspforums.net/");
dt.Rows.Add("aspsnippets", "https://www.aspsnippets.com/");
dlUrls.DataSource = dt;
dlUrls.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 Data.DataTable = New Data.DataTable()
dt.Columns.AddRange(New Data.DataColumn() {
New Data.DataColumn("Name"),
New Data.DataColumn("Url")})
dt.Rows.Add("aspforums", "https://www.aspforums.net/")
dt.Rows.Add("aspsnippets", "https://www.aspsnippets.com/")
dlUrls.DataSource = dt
dlUrls.DataBind()
End If
End Sub