Linked button in a data table

I am building a data table in my page, one of the items is a pdf icon that corresponds to a number drawn from a query (that exists in the datatable).  I want the pdf button to redirect to a page with a string query corresponding to the number in the dataset when one of them is clicked.  

So if the first one is clicked and the query pulls '23432' as the corresponding number I want that passed in the string query as the browser is redirected.

What is the best way to do this?
Who is Participating?
Bob LearnedConnect With a Mentor Commented:
That sounds like a Server.Transfer or Response.Redirect with query string arguments passed.  If you attached an event handler to the hyperlink, then you could have a Response.Redirect in the event handler to go to another page.
Bob LearnedCommented:
What type of ASP.NET web site are you using (Web Forms, MVC, ...)?

What do you mean by "data table"

Are you asking how to generate a dynamic hyper link?

Are you using a GridView?
UnderSevenAuthor Commented:
It is a web form,

I think a dynamic hyper link would do.  The fields come off a data list dynmically populated via a sql query
The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

Bob LearnedCommented:
Can you show me a little of what you are working with please?
UnderSevenAuthor Commented:
This is the current code that works, but you will see in the commented section what I am trying to do.  Rather than it go straight to a page, I want it to go to a new aspx page via string query.

Protected Sub ddlBills_ItemDataBound(ByVal sender As Object, ByVal e As DataListItemEventArgs) Handles ddlBills.ItemDataBound
            If e.Item.ItemType = ListItemType.Item OrElse e.Item.ItemType = ListItemType.AlternatingItem Then
                Dim drow As DataRowView = DirectCast(e.Item.DataItem, DataRowView)
                Dim hl As HyperLink = DirectCast(e.Item.FindControl("lnkFormat"), HyperLink)
                Dim sn As String = drow("StatementNumber").ToString()
                Dim req As System.Net.WebRequest
                Dim res As System.Net.WebResponse

                req = System.Net.WebRequest.Create("" & sn & ".pdf")
                'req = System.Net.WebRequest.Create("" & sn)
                ' req = System.Net.WebRequest.Create("/statements.aspx?statement=" & sn)

                '   Try

                '  res = req.GetResponse()

                ' hl.NavigateUrl = "/statements.aspx?statement=" & sn
                hl.NavigateUrl = "" & sn & ".pdf"

Open in new window

UnderSevenAuthor Commented:
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.