user49722
user49722

Reputation: 49

Grid View-colour

My grid view is showing the details as per the search button.But I want the latest Date row ,to be colured to help the users identify the latest one.Can you please help? Iam using ASP.NET,VB.NET,SQL-2005

Upvotes: 1

Views: 128

Answers (3)

belly
belly

Reputation: 11

Use this

public void NonEventModelHighlighting(Grid grid)
{
    //Initialize the grid
    grid.Headers.Add(new Header());
    grid.Headers[0].Add(new Column("Name"));
    grid.Headers[0].Add(new Column("Color"));
    grid.Headers[0].Add(new Column("Price"));

    //Set highlighting parameters
    grid.Highlighting.Fading = true;
    grid.Highlighting.Interval = TimeSpan.FromSeconds(2);

    //Set semi-transparent color
    grid.Highlighting.Color = Color.FromArgb(128, Color.Red);

    //Populate the grid
    Row rowMercedes = grid.Rows.Add(new object[] { "Mercedes", Color.Black, 25000d });
    Row rowBMW = grid.Rows.Add(new object[] { "BMW", Color.White, 35000d });

    //Cut off the BMW's price - this will highlight the 'Price' cell for 2 seconds with semi-transparent Red color
    rowBMW["Price"].Value = 24000d;

    //Highlight 'BMW' name with the green color for 3 seconds
    rowBMW["Name"].Highlight(TimeSpan.FromSeconds(3), Color.Green);
}

Upvotes: 1

Gregory A Beamer
Gregory A Beamer

Reputation: 17010

You have the ability to intercept the binding of each row, so half the problem is solved outside of the box. _OnRowDatabound works.

The only other part of the solution is getting the max date of the dates shown. You can do this with a second query in the query batch (to avoid a second database hit) or you can do this by looping through the data prior to binding.

When date == max date, you simply change the background color of the cells in the row, or whatever you desire.

Upvotes: 0

Related Questions