ASP/VB logic problem

By Geneticus0 ·
I have a page that I have created with a gridview.

I am taking the values from a column and creating a URL out of them.
I have a button on the page that, when clicked, should open a new browser window with the URL I created in the page.

I have tried this a few different ways with out much success. If I place the URL builder in the ASP page, I don't seem to be able to call the sub automatically so that the URL is built before the user clicks on a button.

If I set the button to run the sub, I can't get a new window opened with the URL from the sub.

If I move all of the vb to the asp.vb page in the onload event, it no longer can see the gridview to build my URL.

Here is what I have at the moment, the page renders but I am missing a way to navigate to the URL....

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">

<script type ="text/VB"  runat="server">

    Public Sub BuildURL()
        Dim index As Integer = AssignedGridView.Rows.Count

        Dim BaseURL As String = ""

        Dim FullURL As String

        Dim Iteration As String

        Dim i As Integer

        FullURL = BaseURL

        For i = 1 To index

            If i = 1 Then

                Iteration = "Site"

            Else : Iteration = "&Site"

            End If

            FullURL = FullURL & Iteration & i & "=" & AssignedGridView.DataKeys(i).Value.ToString()


    End Sub


<html  >

<head id="Head1" runat="server"></head>

    <form id="form1" runat="server">

    <table class="style1" align="center">

            <td class="style2">Assigned Tickets</td>


    <table class="style2" align="center">

        <td class="style3">

         Look at all tickets on map: 
         <input type="button" onclick="BuildURL()" value="Get Map"/>


    <asp:GridView ID="AssignedGridView"









            <asp:BoundField DataField="ref_num" HeaderText="Ticket" 
                SortExpression="ref_num" />

            <asp:BoundField DataField="summary" HeaderText="Summary" 
                SortExpression="summary" />

            <asp:BoundField DataField="location_name" HeaderText="Site" 
                SortExpression="location_name" />

            <asp:BoundField DataField="z_USS_area" HeaderText="Area" 
                SortExpression="z_USS_area" />

            <asp:BoundField DataField="address_5" HeaderText="Map Code" 
                SortExpression="address_5" />

            <asp:BoundField DataField="PCat" HeaderText="Catergory" 
                SortExpression="PCat" />

            <asp:BoundField DataField="address_6" HeaderText="Site Code" 
                SortExpression="address_6" /> 

            <asp:BoundField DataField="status" HeaderText="Status" 
                SortExpression="status" /> 

            <asp:BoundField DataField="priority" HeaderText="Priority" 
                SortExpression="priority" />


        <SelectedRowStyle BackColor="#999999" />


    <asp:SqlDataSource ID="SqlDataSource2" runat="server" 
        ConnectionString="<%$ ConnectionStrings:mdbConnectionString %>" 

        SelectCommand="SELECT [ref_num], [summary], [location_name], [z_USS_area], [address_5], [PCat], [address_6], [status], [priority] FROM [VIEW_USS_A] WHERE ([last_name] = @last_name)">
            <asp:ControlParameter ControlID="DropDownList1" DefaultValue="Choose An Agent" 
                Name="last_name" PropertyName="SelectedValue" Type="String" />







This conversation is currently closed to new comments.

Thread display: Collapse - | Expand +

All Answers

Share your knowledge

Related Discussions

Related Forums