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?
 
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
 
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
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

 
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
 
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:
This is a great out of the box solution
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.