Hi nauna,
Refer below sample code.
HTML
<asp:ListView ID="ListView1" runat="server">
<ItemTemplate>
<div class="all-msgs d-inbox">
<asp:LinkButton ID="LinkButton1" runat="server">View</asp:LinkButton>
<asp:Label ID="Label3" runat="server" Text='<%#Eval("Id") %>' CssClass="badge pull-right theme-bg"></asp:Label>
</ItemTemplate>
</asp:ListView>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript">
$(function () {
$('[id*=LinkButton1]').on('click', function () {
var id = $(this).closest('div').find('[id*=Label3]').html();
var oldURL = window.location.protocol + "//" + window.location.host + window.location.pathname;
if (history.pushState) {
var newUrl = oldURL + "?ID=" + id;
window.history.pushState({ path: newUrl }, '', newUrl);
}
return false;
});
});
</script>
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("Id") });
dt.Rows.Add(1);
dt.Rows.Add(2);
dt.Rows.Add(3);
dt.Rows.Add(4);
ListView1.DataSource = dt;
ListView1.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 System.Data.DataTable = New System.Data.DataTable()
dt.Columns.AddRange(New System.Data.DataColumn() {New System.Data.DataColumn("Id")})
dt.Rows.Add(1)
dt.Rows.Add(2)
dt.Rows.Add(3)
dt.Rows.Add(4)
ListView1.DataSource = dt
ListView1.DataBind()
End If
End Sub
Screenshot