Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Old 03-10-2006, 09:28 AM   #1 (permalink)
rikb53
Registered User
 
Join Date: Jan 2006
Posts: 29
rikb53 is on a distinguished road
Maintain State after postback

i can highlight a dataGrid row thru javascript or in the code behind with the OnItemDataBound Event of the grid.
and yes it highlights, and then goes away on Postback. anyway to make it stick until say an event of maybe a button Click is fired.

Public Sub dtgCustomers_ItemDataBound(ByVal sender As Object, ByVal e As DataGridItemEventArgs)
If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.AlternatingItem Then
e.Item.Attributes.Add("onclick", "this.style.backgroundColor='Yellow'")
End If
End Sub

this works, then goes away on postback
anyideas how to maintain this state????
thanks
rik
rikb53 is offline   Reply With Quote
Old 03-10-2006, 09:40 AM   #2 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,446
sde is on a distinguished road
I sure wish we had more .NET guys around here. Ryan was our resident guru, but he doesn't come around much anymore.
sde is offline   Reply With Quote
Old 03-10-2006, 09:42 AM   #3 (permalink)
rikb53
Registered User
 
Join Date: Jan 2006
Posts: 29
rikb53 is on a distinguished road
darn, i know there's got to be a way either by session state or Caching - but i hate to use a Cach when data will be going in and out
rikb53 is offline   Reply With Quote
Old 03-11-2006, 11:37 AM   #4 (permalink)
rikb53
Registered User
 
Join Date: Jan 2006
Posts: 29
rikb53 is on a distinguished road
i found my answer. its a limitation of the datagrid
A row is selected only if the user clicks the column button associated with the Select command.
There is an architectural issue behind this limitation.
To process the selection event on the server, you need an interactive element on the page that, when clicked, posts back to the server.”

A selected row can have a custom style that you specify by using the SelectedItemStyle property;
Only one row in the DataGrid control can be selected at any time. Multiple selection is not supported.(aka - ListBox)
A row is selected only if the user clicks the column button associated with the Select command And you can get the info for all the cells (e.Item.Cells(0).text = e.Item.Cells(1).text etc)
Each select column must be created using the ButtonColumn class with the CommandName property set to select.
The user can select the row by clicking any of these columns and choose any color which will remain after post-back
rikb53 is offline   Reply With Quote
Old 03-22-2006, 06:52 PM   #5 (permalink)
rdove
Masked Moderator
 
rdove's Avatar
 
Join Date: May 2002
Location: Indianapolis, IN
Posts: 260
rdove is on a distinguished road
Have you tried enabling ViewState?

Also, on post backs, the page_load event is triggered every time a server request occurs. Try using

If Not Page.IsPostBack Then

'some code

End If

This will allow you to keep function calls from being triggered in the event that the page is posted back to the server.
__________________
~Ryan

rdove is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
maintain a chown setting sde Linux / BSD / OS X 7 12-05-2005 09:54 PM


All times are GMT -8. The time now is 11:01 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting