Link to home
Start Free TrialLog in
Avatar of thomashospital
thomashospital

asked on

Passing an ID to a request query string using an asp.net Hyperlink object

I have a repeater that links a series of news stories from a database.  I am trying to pass the ID field through a Hyperlink Object:

<asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl='<%# string.Format("News_Details.aspx?ID={0}", Eval("PKID") ) %>' Text='<%# DataBinder.Eval(Container.DataItem,"Headline") %>' />
        </strong>

The problem I am having is I am not getting a value from the second page in the code behind:

  Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Dim NewsID As String
        NewsID = Page.Request.QueryString("News_Details.aspx?ID=" & ID)
        If Request.QueryString("News_Details.aspx?ID=" & ID) <> Nothing Then
            MsgBox(NewsID.ToString)
        End If

End Sub
Avatar of Jini Jose
Jini Jose
Flag of India image

use simple <a href> instead of asp:hyperlinks
check the below code

<a title='<%# Eval("Title") %>' href='ShowNews.aspx?Id=<%# Eval("Id") %>'> <%# Eval("Title")%>
ASKER CERTIFIED SOLUTION
Avatar of Aksh
Aksh
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of thomashospital
thomashospital

ASKER

Thanks