Hi ramco1917,
Please refer below sample.
HTML
<asp:Label ID="lblHtml" runat="server" />
<div class="modal" tabindex="-1" role="dialog" id="modal_form_horizontal">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Details</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<table class="table">
<tr>
<td>Id</td>
<td>
<asp:Label ID="lblId" runat="server" Font-Bold="true" ForeColor="Red" />
</td>
</tr>
<tr>
<td>Name</td>
<td>
<asp:Label ID="lblName" runat="server" />
</td>
</tr>
<tr>
<td>Status</td>
<td>
<asp:Label ID="lblStatus" runat="server" />
</td>
</tr>
</table>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
</div>
</div>
</div>
</div>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css" />
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript" src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/js/bootstrap.min.js"></script>
<script type="text/javascript">
function BindData(ele) {
$('[id*=lblId]').html($(ele).closest('tr').find('td').eq(0).html());
$('[id*=lblName]').html($(ele).closest('tr').find('td').eq(1).html());
$('[id*=lblStatus]').html($(ele).closest('tr').find('td').eq(2).html());
}
</script>
Namespace
C#
using System.Data;
VB.Net
Imports System.Data
Code
C#
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
List<Data> items = new List<Data>();
items.Add(new Data { CustomerId = "ALFKI", ContactName = "Alfreds Futterkiste", Status = 0 });
items.Add(new Data { CustomerId = "ANATR", ContactName = "Around the Horn", Status = 1 });
items.Add(new Data { CustomerId = "ANTON", ContactName = "Island Trading", Status = 0 });
StringBuilder htmlTable = new StringBuilder();
htmlTable.Append("<table class='table'><tr><th style='display:none'></th><th>Name</th><th>Status</th></tr>");
htmlTable.Append("<tbody>");
foreach (var colum in items)
{
htmlTable.Append("<tr>");
htmlTable.Append("<td style='display:none'>" + colum.CustomerId + "</td>");
htmlTable.Append("<td>" + colum.ContactName + "</td>");
htmlTable.Append("<td>" + colum.Status + "</td>");
htmlTable.Append("<td class='text-center'><a id='btnEdit' style='cursor:pointer;' class='list-icons-item text-primary-600' data-toggle='modal' data-backdrop='static' data-keyboard='false' data-target='#modal_form_horizontal' onclick='BindData(this);'><i class='icon-pencil7 mr-1'></i>Edit</a></td>");
htmlTable.Append("</tr>");
}
htmlTable.Append("</tbody>");
htmlTable.Append("</table>");
lblHtml.Text = htmlTable.ToString();
}
}
public class Data
{
public string CustomerId { get; set; }
public string ContactName { get; set; }
public int Status { get; set; }
}
VB.Net
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
If Not Me.IsPostBack Then
Dim items As List(Of Data) = New List(Of Data)()
items.Add(New Data With {
.CustomerId = "ALFKI",
.ContactName = "Alfreds Futterkiste",
.Status = 0
})
items.Add(New Data With {
.CustomerId = "ANATR",
.ContactName = "Around the Horn",
.Status = 1
})
items.Add(New Data With {
.CustomerId = "ANTON",
.ContactName = "Island Trading",
.Status = 0
})
Dim htmlTable As StringBuilder = New StringBuilder()
htmlTable.Append("<table class='table'><tr><th style='display:none'></th><th>Name</th><th>Status</th></tr>")
htmlTable.Append("<tbody>")
For Each colum In items
htmlTable.Append("<tr>")
htmlTable.Append("<td style='display:none'>" & colum.CustomerId & "</td>")
htmlTable.Append("<td>" & colum.ContactName & "</td>")
htmlTable.Append("<td>" & colum.Status & "</td>")
htmlTable.Append("<td class='text-center'><a id='btnEdit' style='cursor:pointer;' class='list-icons-item text-primary-600' data-toggle='modal' data-backdrop='static' data-keyboard='false' data-target='#modal_form_horizontal' onclick='BindData(this);'><i class='icon-pencil7 mr-1'></i>Edit</a></td>")
htmlTable.Append("</tr>")
Next
htmlTable.Append("</tbody>")
htmlTable.Append("</table>")
lblHtml.Text = htmlTable.ToString()
End If
End Sub
Public Class Data
Public Property CustomerId As String
Public Property ContactName As String
Public Property Status As Integer
End Class
Screenshot