Master/Detail Across Two Pages

Hello there,

I'm doing an ASP.NET page which uses a GridView (with selection enabled)  & I bounded it to a FormVew in the same page, however I need to add another selection column in the same GridView, so I'm trying to do the second part of the following two parts:

when I click the first selection link of any row, it shows the details of that row in the form View in the same page (this is done already)
when I click the second selection link of the same row, it takes me to the details of that row in the FormView at another page (this is what I need to know how)
tryMe2cAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
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.

Manoj PatilSr. Software EngineerCommented:
If you select the second link lets say "View Details". You can Pass the ID of that record as a QueryString to the Page on which you want to display the Details.

In GridView Add following code in your template Field for that Column. ( Change it as per your requirement )

<a href = "#" title="click to view detail" 
onclick="return jsPop2('PopUp_ViewDetails.aspx?ID=<%# DataBinder.Eval (Container.DataItem,"ID")%>');">
<asp:ImageButton ID="ImageButton6" runat="server" ImageUrl="magnifier.png" CommandName="image" CommandArgument='<%# Eval("ID") %>'/>
</a>

Open in new window


Just add following script in your Header Section
<script>
 function jsPop2(URL)
         {
            window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=1,menubar=0,resizable=0,width=700,height=600');
        }
</script>

Open in new window

0
tryMe2cAuthor Commented:
Thank you for this helpful post, but is there anyway, to do it without a client script?
just pure asp.net? is it possible?
0
Manoj PatilSr. Software EngineerCommented:
Yes it is possible, but there is unnecessary post back will occur.  
If you really want to do this then just add an ImabeButton onClick event or ImageButton.OnCommand event

0
Exploring ASP.NET Core: Fundamentals

Learn to build web apps and services, IoT apps, and mobile backends by covering the fundamentals of ASP.NET Core and  exploring the core foundations for app libraries.

Manoj PatilSr. Software EngineerCommented:
In that Event function add Response.Redirect(abc.aspx?ID=2334);
0
tryMe2cAuthor Commented:
I'd like to use it in the gridview, so how could I make sure it selects the same row of the gridview?
0
Manoj PatilSr. Software EngineerCommented:
OK. If you want to use gridView, then you can get the selected row by using GridView Property onRowCommand


In row command if you want to get the current row or its index, It is not directly possible. There is two way, one is on row created event on the link button(suppose, it is used for row command) save row index in link button command argument attribute.(see very first comment)

And get the argument from row command event using e.CommandArgument

But if you want to send another value as a command argument then it creates problem. To solve this just use this code

GridViewRow row = (GridViewRow)(((ImageButton)e.CommandSource).NamingContainer);

Here link button (or any source) that cause to enter in row command event. Now you have selected row so you don’t need any index and directly access any row variable as sample code is given below
Label lblProdId = (Label)row.FindControl(“lblproductId”);

OR to select row index

int RowIndex = gvr.RowIndex;

So whole code is just two line. Below I write whole code

GridViewRow row = (GridViewRow)(((ImageButton)e.CommandSource).NamingContainer);

Label lblProdId = (Label)row.FindControl(“lblproductId”);

OR

int RowIndex = gvr.RowIndex;
0
tryMe2cAuthor Commented:
Actually you write things look really great, but honestly I have no idea how to implement these technique suggested by you

anyways, I've spend few days reading in the msdn, & finally I got the solution as following:

Add a hyperLinkField to the gridView
Set its DataNavigateUrlField to the row rowID variable name, which is DeviceID in my case
set its DataNavigateUrlFormatString to the destinationPage.aspx?rowID={0}

and batta bing batta boom :P
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
tryMe2cAuthor Commented:
This is a great out of the box solution
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
ASP.NET

From novice to tech pro — start learning today.