Hi nauna,
Set the QueryString value in a HiddenField and use that in the code to Filter record.
HTML
<asp:ScriptManager runat="server" />
<asp:UpdatePanel runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:Timer ID="timer" runat="server" Interval="2000" OnTick="Timer1_Tick">
</asp:Timer>
<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>
<asp:Label ID="lblID" runat="server" />
<asp:HiddenField ID="hfQuerStringID" runat="server" />
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="timer" EventName="Tick" />
</Triggers>
</asp:UpdatePanel>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript">
$('body').on('click', '[id*=LinkButton1]', 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);
$('#hfQuerStringID').val(id);
}
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();
}
}
protected void Timer1_Tick(object sender, EventArgs e)
{
if (!string.IsNullOrEmpty(hfQuerStringID.Value))
{
string id = hfQuerStringID.Value;
lblID.Text = id;
}
}
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
Protected Sub Timer1_Tick(ByVal sender As Object, ByVal e As EventArgs)
If Not String.IsNullOrEmpty(hfQuerStringID.Value) Then
Dim id As String = hfQuerStringID.Value
lblID.Text = id
End If
End Sub