Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Highlighting previously selected item on gridview

Status
Not open for further replies.

furtivevole

Technical User
Jun 21, 2001
84
0
0
GB
Hi I have a gridview which includes a hidden ID field, a customer name field, and some other basic customer-related stuff. This is displayed in a panel with scrollbars at the top of the page, and the displayed columns are all sortable. The panel is 5 lines deep and so can display only a fraction of the full customer list at once.

The customer name field is a HyperLinkField, set to return to the same page:
Code:
DataNavigateUrlFormatString="CustomerProfiles.aspx?CustID={0}"
which will then display fuller customer details in a lower panel. On page reload, ths upper panel with the scrollable list should remain available for any further selection.

The problem is that I'd like the chosen customer to always come back visible and highlighted in the upper panel. In good old asp classic, you could use the querystring value to test against the value of each html list entry, and set the one that matched to 'selected'. I guess under .net this must be similar, but I've not been able to find an example. Can anyone help here please?
 
I did the same thing in a project. What I did was saved my ID property into ViewState, then looked for that value on postback:
(RowDataBound event of the gridview)
Code:
If e.Row.Cells(0).Text = ViewState("YourID") Then
   e.Row.BackColor = Color.Yellow
End If
 
Hi jbenson
Thanks (belatedly) for your reply. Maybe I didn't express the requirement clearly enough. There are a lot of records, 3 sort sequences, and a 5-row deep window. I'd like to be able to make sure the selected row always remains visible in that window on postback.

Thanks, vole.
 
Then that is a scrolling issue, not a highlighting issue. There have been posts in here regarding that. Basically you have to use javascript. I have seen posts in the javascript forum with code samples.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top