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

BOEING39Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

duttcomCommented:
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.
0
Rahul AgarwalTeam LeaderCommented:
Just pass the query string with the help of hyperlink field

Reference:

http://stackoverflow.com/questions/6539667/how-to-bind-the-url-of-a-gridview-hyperlinkfield-when-the-bound-value-contains-a
http://forums.asp.net/t/1139035.aspx

and on 2nd grid define query string control parameters like

<SelectParameters>

        <asp:QueryStringParameter Name="CustomerId" DbType = "String" Direction = "Input" QueryStringField="Id" DefaultValue="" ConvertEmptyStringToNull="True" />

    </SelectParameters>

reference:

http://www.aspsnippets.com/Articles/ASPNet-SqlDataSource-pass-value-to-SelectParameter-using-QueryString-Parameter-Example.aspx
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
BOEING39Author Commented:
Can you provide an example with the code I have provided?
0
BOEING39Author Commented:
Agar, I utilized your references to come up with the solution passing the query based on "Ship" @ {0} on to the 2nd page.   Thanks.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C#

From novice to tech pro — start learning today.