Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Datagrid Control > alternating item style in template row with table tags

Reply
Thread Tools

alternating item style in template row with table tags

 
 
NancyASAP
Guest
Posts: n/a
 
      07-12-2005
In case anyone else runs into this issue...

I recently wanted to set alternating item style on a grid row that
contained a template item for the entire row. This template item
contained html table tags. This allowed me to make each single grid row
a multiple row table (I needed each grid row to be 3 rows worth of
stuff).

However, when I tried to set alternating item style on the grid, row
background color was not visible because table row tags superceded it -
essentially were laying over the color so that it never showed.

To fix this, I had to dynamically set a background color on the
embedded html table rows in the datagrid template item. I gave the html
row tags <tr's> a unique id attribute (id=myid), and set the runat
attribute to server (runat=server). Both attributes are necessary! Then
in the grid ItemDataBound event, I put this code in (where "row1Valid"
was my unique <tr> tag id):

If e.Item.ItemType = ListItemType.AlternatingItem Then
Dim row As HtmlTableRow = CType(e.Item.FindControl("row1Valid"),
HtmlTableRow)
row.Style.Add("background-color", "#E0E0E0;")
End If

Put in the Style Add command for each tr tag in the item template.
Worked great! Hope this helps someone else.
Nancy Steinmann
MCSD .NET

 
Reply With Quote
 
 
 
 
Fiaz Ali Saleemi
Guest
Posts: n/a
 
      07-14-2005
Hi Nancy

Thanks for sharing your experience and knowledge this will definetly help.

Regards
Fiaz Ali Saleemi


 
Reply With Quote
 
 
 
Reply

Thread Tools

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Alternating Item Style in a ListBox Rob ASP .Net 4 03-10-2011 10:02 AM
Alternating Row style in DataGridView mike@5starserv.com ASP .Net 4 01-25-2007 02:58 PM
Alternating Item Style "ForeColor" not working in Template Column =?Utf-8?B?TWF4IFdlZWJsZXI=?= ASP .Net 9 10-27-2005 06:06 PM
All style tags after the first 30 style tags on an HTML page are not applied in Internet Explorer Rob Nicholson ASP .Net 3 05-28-2005 03:11 PM
Change style of a single row of the item list of datagrid, based on a field value of current item... QUASAR ASP .Net Datagrid Control 6 01-17-2004 07:46 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57