How to pass query string in hyperlink in asp net

Pass query string in hyperlink in asp net

Today, I am going to show with you "how we can pass query string in the hyperlink". So let's get started step by step tutorial of passing query string in the hyperlink. Many times a situation arrives when we need to pass query string from one page another page by hyperlink. If you want to use hyperlink with query string, also this tutorial will helpful for you.

How to pass query string in hyperlink in asp net, multiple query string in gridview

Step to implement the query string with hyperlink

1. Add an server-side hyperlink control.
2. Put the value and key in herf attributes.
3. URL of the page on which you want to redirect.

Use Single Query in hyperlink

  <asp:TemplateField HeaderText="View">
         <asp:HyperLink ID="HyperLink1" ForeColor="red" Text="view" Target="_blank"
       runat="server" NavigateUrl='<%#"StudentView.aspx?id="+Eval("StudentID").ToString()%>'></asp:HyperLink>

How to use multiple query string in hyperlink in in grid view

    <asp:TemplateField HeaderText="View">
            <asp:HyperLink runat="server" NavigateUrl='<%# string.Format("~/Details.aspx?StudentID={0}&StudentName={1}", (Eval("Empsalary").ToString()),
    (Eval("Empsalary").ToString())) %>' Text="View" Target="_blank"/>

If you have any issue, please drop a comment below. We will happy to help you.

Post a Comment

Post a Comment (0)

Previous Post Next Post