Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Select in Gridview with postbackurl

Posted on 2008-06-20
5
Medium Priority
?
993 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 2000 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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

There’s a good reason for why it’s called a homepage – it closely resembles that of a physical house and the only real difference is that it’s online. Your website’s homepage is where people come to visit you. It’s the family room of your website wh…
Dramatic changes are revolutionizing how we build and use technology. Every company is automating, digitizing, and modernizing operations. We need a better, more connected way to work together as teams so we can harness the insights from our system…
This video teaches users how to migrate an existing Wordpress website to a new domain.
The viewer will learn how to dynamically set the form action using jQuery.
Suggested Courses

721 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