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 asp.net 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">
    <ItemTemplate>
         <asp:HyperLink ID="HyperLink1" ForeColor="red" Text="view" Target="_blank"
       runat="server" NavigateUrl='<%#"StudentView.aspx?id="+Eval("StudentID").ToString()%>'></asp:HyperLink>
    </ItemTemplate>
    </asp:TemplateField>



How to use multiple query string in hyperlink in asp.net in grid view

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

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