Solved

Select in Gridview with postbackurl

Posted on 2008-06-20
5
984 Views
Last Modified: 2008-06-24
I have a gridview in my form. My goal is to allow users to select a record and:

1 - have in write a session variable.
2 - Postback to a 2nd page .
3 - When the user closes out of the 2nd page, have the record that was selected highlighted.

When I enable select in my gridview  I can do 1 & 3, but not 2.
When I have a hyperlink I can do 2, but not 1&3.

How can I accomplish all three goals with one click?
0
Comment
Question by:billkrieger
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 22

Expert Comment

by:prairiedog
ID: 21831789
>>>When the user closes out of the 2nd page, have the record that was selected highlighted.
Is the 2nd page a pop-up?
0
 

Author Comment

by:billkrieger
ID: 21832087
No, it is not a pop up page. In my datagrid I have a record set that is reading from a stored procedure that is pulling from different tables. When the user selects a record in the datagrid, I am assigning the recordID (related field) as a session variable. The second page is a frame page that has three frames that will pull data matching the session variable.

Currently I have the select button enabled in my gridview which sets my session variable on selectedindexchange and the selected Item gets highlighted. I have a button that will postbackurl to the framed page on click. The framed page opens fine, and when the browsers back button is clicked the user goes back to the original page and the selected item is still highlighted in my gridview.

I would like to eliminate the process of having to click the button after selecting a record. I would like the framed page to open when the user clicks on select in the datagrid.

I changed my gridview to have a hyperlink. This opened my frame page, but did not set my session variable.

Thanks for your help!
0
 
LVL 22

Accepted Solution

by:
prairiedog earned 500 total points
ID: 21835206
In GridView's RowDataBound event handler, you can do this:
Private Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView1.RowDataBound
        If (e.Row.RowType = DataControlRowType.DataRow) Then
            If (Session("RowIndex") IsNot Nothing) Then
                If (e.Row.RowIndex = Int32.Parse(Session("RowIndex").ToString())) Then
                    e.Row.BackColor = Drawing.Color.Yellow    <====change to whatever color you want
                End If
            End If
        End If
    End Sub

But this is not going to work if user clicks browser's Back button. What you can do is to put a link on the 2nd page to redirect user back to the 1st page.
0
 

Author Comment

by:billkrieger
ID: 21857740
Thanks, I will give it a try. on a page with three frames, how do put a link that will close out of all frames and open the 1st page?
0
 

Author Comment

by:billkrieger
ID: 21858085
ok. not sure what I was thinking. the simple way to do what I was looking for was to
Response.Redirect after setting my session variables and code on the selectedindexchange. Thanks for your help.
0

Featured Post

Are You Using the Best Web Development Editor?

The worlds of web hosting and web development are constantly evolving. Every year we see design trends change, coding standards adapt and new frameworks/CMS created. With such a quick pace of change it’s easy to get lost trying to keep up.

See if your editor made the list.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

FAQ pages provide a simple way for you to supply and for customers to find answers to the most common questions about your company. Here are six reasons why your company website should have a FAQ page
When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

623 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question