Question

Locked

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" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


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

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

        Dim BaseURL As String = "http://10.4.1.251/mappy/getmap.php?"

        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()


        Next

    
    End Sub


</script>


<html  >

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

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


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

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

       
     </table>


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

        
        <td class="style3">

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

                   
    </table>
    <br/>

    <asp:GridView ID="AssignedGridView"
                    runat="server" 

                    AutoGenerateColumns="False" 

                    DataSourceID="SqlDataSource2" 

                    AllowSorting="True" 

                    AutoGenerateSelectButton="True"     

                    CellPadding="6" 

                    HorizontalAlign="Center"

                    datakeynames="address_6","status">

        <Columns>

            <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" />

        </Columns>

            
        <SelectedRowStyle BackColor="#999999" />

            
    </asp:GridView>

    <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)">
        <SelectParameters>
            <asp:ControlParameter ControlID="DropDownList1" DefaultValue="Choose An Agent" 
                Name="last_name" PropertyName="SelectedValue" Type="String" />
        </SelectParameters>

    </asp:SqlDataSource>

    <div>

    
    </div>

    </form>
   

</body>

</html>


This conversation is currently closed to new comments.

0 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Answers

Share your knowledge
Back to Networks Forum
0 total posts (Page 1 of 1)  

Related Discussions

Related Forums