Solved

Select in Gridview with postbackurl

Posted on 2008-06-20
5
975 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

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

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

Developer portfolios can be a bit of an enigma—how do you present yourself to employers without burying them in lines of code?  A modern portfolio is more than just work samples, it’s also a statement of how you work.
Color can increase conversions, create feelings of warmth or even incite people to get behind a cause. If you want your website to really impact site visitors, then it is vital to consider the impact color has on them.
This tutorial walks through the best practices in adding a local business to Google Maps including how to properly search for duplicates, marker placement, and inputing business details. Login to your Google Account, then search for "Google Mapmaker…
The is a quite short video tutorial. In this video, I'm going to show you how to create self-host WordPress blog with free hosting service.

739 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