Solved

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

Posted on 2010-08-25
3
720 Views
Last Modified: 2012-05-10
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
0
Comment
Question by:thomashospital
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 10

Expert Comment

by:Jini Jose
ID: 33523596
use simple <a href> instead of asp:hyperlinks
check the below code

<a title='<%# Eval("Title") %>' href='ShowNews.aspx?Id=<%# Eval("Id") %>'> <%# Eval("Title")%>
0
 
LVL 6

Accepted Solution

by:
Aksh earned 500 total points
ID: 33523690
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
0
 

Author Closing Comment

by:thomashospital
ID: 33523871
Thanks
0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…

751 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question