Gridview header link to another page or website.

The following source code shows how to change another frame url. Ensure there is “return false;” otherwise no operation will happen. Notice there is an extra parameter added in the url: “&time=” & Date.Now.Millisecond, the reason is the browser won’t refresh the webpage if the previous url the same as the new one instead just get the content from cache. So add this millisecond parameter, it will change the url every time and got refresh.

Dim myURL As String = "anotherpage.aspx?id1=" & id1.ToString.Trim & "id2=" & id2.ToString.Trim 

myURL = "window.parent.document.getElementById('RightFrame').src='" & myURL & "&time=" & Date.Now.Millisecond & "';return false;"

        Select Case carclass.cartypeID
            Case 1, 3   
                gdview.HeaderRow.Cells(1).Text = "<a href='' onclick=""" & myURL & """> car " & carclass.cartypeid & "</a>"
            Case 2      
                gdview.HeaderRow.Cells(1).Text = "<a href='' onclick=""" & myURL & """> " & carclass.cartypeid & "</a>"
            Case Else
                gdview.HeaderRow.Cells(1).Text = String.Empty

        End Select

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s