Solved

Select in Gridview with postbackurl

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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Learn by example how to specify CSS selectors for Selenium WebDriver test automation software.
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

810 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