Link to home
Start Free TrialLog in
Avatar of BOEING39
BOEING39

asked on

GRIDVIEW HYPERLINK

I have a GridView page named "Home1All" that has a "Hyperlink" Column named "UpLoad View".  

This hyperlink directs the user to a new page "FileUpload1/Default.aspx"  

The Default page contains another GridView which does displays properly; however, I need help in establishing a filter on the 2nd GridView based on a value from the 1st namely "Ship".

So when When the Hyperlink is clicked I need the corresponding value for  "Ship" to be passed to the 2nd Gridview Querry so that the 2nd GridView only displays all data pertaining to that Ship #.
   

GRIDVIEW #1 (Sniplet #1) Home1All Hyperlink

GRIDVIEW #2:  (Sniplet#2)  FileUpload1/Default.aspx  Hyperlinked Page, Displaying specific Ship# data based on respective ship number associated with "Home1All" GridView row.
<asp:hyperlinkfield DataNavigateUrlFormatString="FileUpload1/Default.aspx" NavigateUrl="../FileUpload1/Default.aspx" Text="Docs" HeaderText="Upload View">
				<ControlStyle ForeColor="Blue" />
				<HeaderStyle HorizontalAlign="Center" Wrap="True" Width="35px" />
				<ItemStyle HorizontalAlign="Center" Wrap="False" Width="35px" />
</asp:hyperlinkfield>

Open in new window

<asp:SqlDataSource ID="SqlDataSource3" runat="server" 
                        ConnectionString="<%$ ConnectionStrings:AllegiantMXConnectionString %>" 
                        DeleteCommand="DELETE FROM [fileDet] WHERE [ID] = @ID" 
                        InsertCommand="INSERT INTO [fileDet] ([fname], [fpath], [desc1], [Ship], [Dates], [Sta]) VALUES (@fname, @fpath, @desc1, @Ship, @Dates, @Sta)" 
                        SelectCommand="SELECT * FROM [fileDet] ORDER BY [Dates] DESC" 
                        UpdateCommand="UPDATE [fileDet] SET [fname] = @fname, [fpath] = @fpath, [desc1] = @desc1, [Ship] = @Ship, [Dates] = @Dates, [Sta] = @Sta WHERE [ID] = @ID">
                        <DeleteParameters>
                            <asp:Parameter Name="ID" Type="Int32" />
                        </DeleteParameters>
                        <InsertParameters>
                            <asp:Parameter Name="fname" Type="String" />
                            <asp:Parameter Name="fpath" Type="String" />
                            <asp:Parameter Name="desc1" Type="String" />
                            <asp:Parameter Name="Ship" Type="String" />
                            <asp:Parameter Name="Dates" Type="String" />
                            <asp:Parameter Name="Sta" Type="String" />
                        </InsertParameters>
                        <UpdateParameters>
                            <asp:Parameter Name="fname" Type="String" />
                            <asp:Parameter Name="fpath" Type="String" />
                            <asp:Parameter Name="desc1" Type="String" />
                            <asp:Parameter Name="Ship" Type="String" />
                            <asp:Parameter Name="Dates" Type="String" />
                            <asp:Parameter Name="Sta" Type="String" />
                            <asp:Parameter Name="ID" Type="Int32" />
                        </UpdateParameters>

Open in new window

Avatar of duttcom
duttcom
Flag of Australia image

I have an example of something similar. In this example, I have a page which shows all shipment information available; a ship and a date are selected from two dropdowns and then when the user clicks on a button, the selected ship and date are passed to another page where the detail for that shipment are seen in full. The destination page uses a listview, but that makes no difference to the way this works.

On my source page, this is my button code where I get the values from the two dropdowns and form a url to open my detail page.

protected void Button1_Click(object sender, EventArgs e)
{
    //Get field values from dropdowns
    string passShip = ShipsDD.SelectedValue;
    string passDelDate = DelDateDD.SelectedValue;
    Response.Redirect("OrderReview.aspx?Ship=" + passShip + "&DelDate=" + passDelDate);
}

Open in new window


On the destination page I have two labels which show the Ship and delivery date I selected in the source page. These could be hidden, but I think it's alaways good to see the parent details when one drills down to detal.

Ship <asp:Label ID="LabelShip" runat="server" Text="Label"></asp:Label>
Date <asp:Label ID="LabelDelDate" runat="server" Text="Label"></asp:Label>

Open in new window


In the code behind on the destination page, I have the following -

protected void Page_Load(object sender, EventArgs e)
    {
        string myShip = Request.QueryString["Ship"];
        string myDelDate = Request.QueryString["DelDate"];
        LabelShip.Text = myShip;
        LabelDelDate.Text = myDelDate;
    }

Open in new window


The ListView on the desination page shows the detail of the ship and date I selected because its select parameters use the two labels as controlparameters when selecting the shipment details.

I hope this is of some use to you.
ASKER CERTIFIED SOLUTION
Avatar of Rahul Agarwal
Rahul Agarwal
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of BOEING39
BOEING39

ASKER

Can you provide an example with the code I have provided?
Agar, I utilized your references to come up with the solution passing the query based on "Ship" @ {0} on to the 2nd page.   Thanks.