Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/35.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net 从GridView超链接中的QueryString参数传递值_Asp.net_Gridview_Query String - Fatal编程技术网

Asp.net 从GridView超链接中的QueryString参数传递值

Asp.net 从GridView超链接中的QueryString参数传递值,asp.net,gridview,query-string,Asp.net,Gridview,Query String,我将GridView与HyperLink列一起使用,我希望执行以下操作: <asp:HyperLinkField DataNavigateUrlFields="DID" DataNavigateUrlFormatString="~/student/group/document/Body.aspx?DID={0}&GN={QueryString("GN")}" HeaderText="View Document" Text="view" /> 如何从QueryStri

我将
GridView
HyperLink
列一起使用,我希望执行以下操作:

<asp:HyperLinkField DataNavigateUrlFields="DID"  
DataNavigateUrlFormatString="~/student/group/document/Body.aspx?DID={0}&GN={QueryString("GN")}" HeaderText="View Document" Text="view" />


如何从
QueryString
参数中检索GN值并将其添加到
HyperLink
列中?

在标记中执行此操作对您有多重要?我很确定您不能在带有
DataNavigateUrlFields
DataNavigateUrlFormatString
的标记中执行此操作,但您可以在RowDataBound事件的代码中执行此操作:

Private Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView1.RowDataBound

    Dim link As HyperLink
    Dim row As DataRow

    If e.Row.RowType = DataControlRowType.DataRow Then
        'Get the row we are binding to
        row = CType(e.Row.DataItem, DataRowView).Row

        'Find the hyperlink control we want to set the link for
        link = CType(e.Row.Controls(1).Controls(0), HyperLink)

        'Check if the querystring we want to include is missing or empty
        If Request.QueryString("GN") Is Nothing Or Request.QueryString("GN") Is String.Empty Then
            'If there is no querystring then we can only bind to the DID
            link.NavigateUrl = "~/student/group/document/Body.aspx?DID=" & row.Item("DID").ToString

        Else
            'The querystring element is present so include it in the link
            link.NavigateUrl = "~/student/group/document/Body.aspx?DID=" & row.Item("DID").ToString & "&GN=" & Request.QueryString("GN").ToString

        End If

    End If

End Sub