Results 1 to 4 of 4

Thread: Datagrid Dynamic Row Colour - How?!?!

  1. #1
    Join Date
    Jun 2005
    Location
    Tunbridge Wells, Kent
    Posts
    206
    Thanks
    6
    Thanked 2 Times in 2 Posts

    Default Datagrid Dynamic Row Colour - How?!?!

    i'm having trouble with the datagrid with vb.net...

    i don't want one row color, i don't want an alternating row color, i most definately don't want no row colour at all!!

    all i want this Christmas is the ability to dynamically set the backcolor of a datagrid row with a color stored in a column in the retrieved table. i can't find any examples, and keep getting myself more and more lost... an example of changing an item style, but not row... argh.. help!

    http://msdn2.microsoft.com/en-us/lib...itemstyle.aspx


    OR (no, and!..)

    has anyone come across a fine example in vb.net of paging the repeater, as although it's not built in, it can use the paging class...

  2. #2
    Join Date
    Sep 2006
    Posts
    210
    Thanks
    1
    Thanked 6 Times in 6 Posts

    Default

    Hi

    Well I have not done a row but have done a column on a Gridview in Vs 2005, did it as follows

    Created a Field in the Database table, I then created a 3 Class's in my Style Sheet, (I only wanted 3 colors) and then I insert the name of the class I want to use for that row color in the new field in my table.

    The Column in the Gridview I want to color I converted to a template column, then in the Item template I put a table and the table class I bind to the new feild in the database table like so

    <tableclass='<%# Eval("Acc_CssClass") %>'style="width: 100%; height: 100%">
    <tr>
    <tdstyle="width: 60px">
    <asp:LabelID="Label11"runat="server"Text='<%# Bind("AccountID") %>'></asp:Label></td>
    </tr>
    </table>

    that works a treat for a column, I have not tried to do a whole row tho

  3. #3
    Join Date
    Jan 2006
    Posts
    419
    Thanks
    2
    Thanked 16 Times in 16 Posts

    Default

    You should be able to use the item databound event

    check the event is from an of type item or alternating item

    extract the colour from the drop down list from the current row using the findcontrol method checking that what you find is not null

    apply a css class to the current row according to the value retrieved above.

  4. #4
    Join Date
    Jun 2005
    Location
    Tunbridge Wells, Kent
    Posts
    206
    Thanks
    6
    Thanked 2 Times in 2 Posts

    Default Paging a Repeater

    thanks for the tips, i'll take a closer look for future reference - my main reason for using the datagrid was for the inbuilt paging... but i found this great example for paging a repeater (i enjoy the flexibility of a repeater) by importing the PagedDataSource Class... works a treat.

    http://www.sitepoint.com/article/asp...eddatasource/5

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Hosting a site on a dynamic IP
    By Jaro in forum General Technical Support
    Replies: 3
    Last Post: 27th September 2006, 01:05 AM
  2. DataGrid - how to add styles to the buttoncolum?
    By creativeworks in forum ASP.NET
    Replies: 2
    Last Post: 6th February 2006, 10:29 AM
  3. Dynamic Avatar images
    By nick in forum Community Feedback and Suggestions
    Replies: 6
    Last Post: 1st December 2005, 09:34 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •