Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
ASP.NET GridView 2.0 DynamicBackColor ?
Message
From
07/04/2006 14:18:33
Keith Payne
Technical Marketing Solutions
Florida, United States
 
 
To
07/04/2006 13:42:27
General information
Forum:
ASP.NET
Category:
Other
Miscellaneous
Thread ID:
01111476
Message ID:
01111497
Views:
20
This message has been marked as a message which has helped to the initial question of the thread.
>Still swimming upstream on ASP.NET, C#2.0 and grids.
>
>I have a GridView (2.0) that shows a list of names in one column, a checkbox in the other.
>The user can click some checkboxes to request a user deletion from the system, pressign Submit.
>I then traverse the GridView Rows collection and get records where chkBox=true.
>
>A SQL INSERT is then prepared for each record and sent as a batch to a SQL Server table which will be picked up sometime later by another app (not mine). The requests table has these recs marked as pending until someday they will be processed.
>
>In the meantime, I have to repaint the GridView (and do the same in every other program instance in the future), showing the records that are still Pending as disabled or maybe some other color or visual indication.
>
>The idea is that I need to get all the available users and the ones marked as Pending in this new table. I have two queries and get two DataSets with this info (different servers and databases).
>
>I am now at the point of coding the next step. Do I again traverse the Row collection and find a matching User_Id record in pending, then how do I change a color or another attributes of one GridView row? Does it have something similar to VFP's DynamicBckColor? Would a Template do the job? I see they are mainly for "Edit" mode, one row at a time which is not what I want.
>
>TIA,

Alex,

There might be a slicker way in 2.0, but in 1.1 this can be accomplished in a couple of different ways:

1. Hook the Item_Created Grid event and change the backcolor or style attribute of the HTML table cells in the row based on the value of underlying data.

2. In the pages's PreRender event, manually traverse the TR and TD elements in the Grid's HTML table and adjust the backcolor or style attributes the same as above.

I think the first option is the easier one because the data and controls are readily available in the DataGridEventArgs parameter.

This might be easier in 2.0, so I'd wait for another response before bothering with the "old" techniques.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform