In this article I will explain with an example, how to bind QueryString Parameters (Single or Multiple) using NavigateUrl property of HyperLink and Eval function inside GridView in ASP.Net using C# and VB.Net.
 
 
Source Page
HTML Markup
The below HTML Markup consists of an ASP.Net GridView with 4 columns. The first and fourth column have HyperLink controls inside the ItemTemplate of TemplateField column.
The second and third columns are BoundField columns.
NavigateUrl with Single QueryString Parameter
In the first column, the value of ID field is set as QueryString parameter.
NavigateUrl='<%# Eval("Id", "~/Details.aspx?Id={0}") %>'
 
NavigateUrl with Multiple QueryString Parameters
In the fourth column the ID, Name and Country fields are set as QueryString parameters.
NavigateUrl='<%# string.Format("~/Details.aspx?Id={0}&Name={1}&Country={2}",
HttpUtility.UrlEncode(Eval("Id").ToString()), HttpUtility.UrlEncode(Eval("Name").ToString()), HttpUtility.UrlEncode(Eval("Country").ToString())) %>'
 
Note: The values of all the ID, Name and Country fields are encoded and then set as set as QueryString parameters.
 
<asp:GridView ID="GridView1" HeaderStyle-BackColor="#3AC0F2" HeaderStyle-ForeColor="White"
    RowStyle-BackColor="#A1DCF2" AlternatingRowStyle-BackColor="White" AlternatingRowStyle-ForeColor="#000"
    runat="server" AutoGenerateColumns="false">
    <Columns>
        <asp:TemplateField HeaderText = "Id" ItemStyle-Width="30">
            <ItemTemplate>
                <asp:HyperLink runat="server" NavigateUrl='<%# Eval("Id", "~/Details.aspx?Id={0}") %>'
                    Text='<%# Eval("Id") %>' />
            </ItemTemplate>
        </asp:TemplateField>
        <asp:BoundField DataField="Name" HeaderText="Name" ItemStyle-Width="150" />
        <asp:BoundField DataField="Country" HeaderText="Country" ItemStyle-Width="150" />
        <asp:TemplateField>
            <ItemTemplate>
                <asp:HyperLink runat="server" NavigateUrl='<%# string.Format("~/Details.aspx?Id={0}&Name={1}&Country={2}",
                    HttpUtility.UrlEncode(Eval("Id").ToString()), HttpUtility.UrlEncode(Eval("Name").ToString()), HttpUtility.UrlEncode(Eval("Country").ToString())) %>'
                    Text="View Details" />
            </ItemTemplate>
        </asp:TemplateField>
    </Columns>
</asp:GridView>
 
 
Namespaces
You will need to import the following namespace.
C#
using System.Data;
 
VB.Net
Imports System.Data
 
 
Binding the ASP.Net GridView control
The GridView is populated with a dynamic DataTable with some dummy data inside the Page Load event.
Note: You can learn more about this dynamic DataTable in my article Create DataTable dynamically and bind to GridView in ASP.Net.
 
C#
protected void Page_Load(object sender, EventArgs e)
{
    if (!this.IsPostBack)
    {
        DataTable dt = new DataTable();
        dt.Columns.AddRange(new DataColumn[3] { new DataColumn("Id"), new DataColumn("Name"), new DataColumn("Country") });
        dt.Rows.Add(1, "John Hammond", "United States");
        dt.Rows.Add(2, "Mudassar Khan", "India");
        dt.Rows.Add(3, "Suzanne Mathews", "France");
        dt.Rows.Add(4, "Robert Schidner", "Russia");
        GridView1.DataSource = dt;
        GridView1.DataBind();
    }
}
 
VB.Net
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
    If Not Me.IsPostBack Then
        Dim dt As New DataTable()
        dt.Columns.AddRange(New DataColumn(2) {New DataColumn("Id"), New DataColumn("Name"), New DataColumn("Country")})
        dt.Rows.Add(1, "John Hammond", "United States")
        dt.Rows.Add(2, "Mudassar Khan", "India")
        dt.Rows.Add(3, "Suzanne Mathews", "France")
        dt.Rows.Add(4, "Robert Schidner", "Russia")
        GridView1.DataSource = dt
        GridView1.DataBind()
    End If
End Sub
 
 
Destination Page
HTML Markup
The following HTML Markup consists of three Label controls for displaying the QueryString parameter values sent from Source page.
<table>
    <tr>
        <td>
            <b>Id</b>
        </td>
        <td>
            <asp:Label ID="lblId" runat="server"></asp:Label>
        </td>
    </tr>
    <tr>
        <td>
            <b>Name</b>
        </td>
        <td>
            <asp:Label ID="lblName" runat="server"></asp:Label>
        </td>
    </tr>
    <tr>
        <td>
            <b>Country</b>
        </td>
        <td>
            <asp:Label ID="lblCountry" runat="server"></asp:Label>
        </td>
    </tr>
</table>
 
 
Fetching the QueryString parameter values
Inside the Page Load event, the values of the QueryString parameters sent from the Source page are extracted, decoded and assigned to the respective Label controls.
C#
protected void Page_Load(object sender, EventArgs e)
{
    if (!this.IsPostBack)
    {
        lblId.Text = HttpUtility.UrlDecode(Request.QueryString["Id"]);
        lblName.Text = HttpUtility.UrlDecode(Request.QueryString["Name"]);
        lblCountry.Text = HttpUtility.UrlDecode(Request.QueryString["Country"]);
    }
}
 
VB.Net
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
    If Not Me.IsPostBack Then
        lblId.Text = HttpUtility.UrlDecode(Request.QueryString("Id"))
        lblName.Text = HttpUtility.UrlDecode(Request.QueryString("Name"))
        lblCountry.Text = HttpUtility.UrlDecode(Request.QueryString("Country"))
    End If
End Sub
 
 
Screenshots
The GridView control with HyperLinks
Bind (Single or Multiple) QueryString Parameters to NavigateUrl of HyperLink using Eval function inside ASP.Net GridView
 
The values of QueryString parameters
Bind (Single or Multiple) QueryString Parameters to NavigateUrl of HyperLink using Eval function inside ASP.Net GridView
 
 
Demo
 
 
Downloads