Question : 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

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

Hi,

I think, the way you are retrieving the query string in second page is not appropriate.

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not Request.QueryString("ID") Is Nothing Then
             Dim NewsID As String = CType(Request.QueryString("ID"), String)
             Response.Write(NewsID)
        Else
             Response.Write("Problem with the first page: No QueryString sent!")
        End If
End Sub

-Aksh
Random Solutions  
 
programming4us programming4us