Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 712607
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T04:52:01+00:00 2026-05-14T04:52:01+00:00

how to detect grid view empty cell ? I need it for highlighting. So

  • 0

how to detect grid view empty cell ? I need it for highlighting. So I made a css

.RedColored 
{
    background: FF0000;
}

and trying to appear it to empty GV cells this way :

protected virtual GridView1_RowDataBound (_sender : object,  e : System.Web.UI.WebControls.GridViewRowEventArgs) : void
        {
            e.Row.Cells[0].CssClass = "wide";
            foreach(i : int in [0..e.Row.Cells.Count-1])
            {
                when(e.Row.Cells[i].Text==null)
                {
                    e.Row.Cells[i].CssClass="RedColored";
                }
            }
        } 

but my it doesn’t appears to empty cells , even I’ve tried
Text==”” , Cell[i]==null, Cell[i].ToString()==”” and nothing helped.

recoded to :            

def IsCellNull(cell : TableCell) : bool
            {
                | null => true
                | c => string.IsNullOrEmpty(c.ToString()) || c.GetType().Name == "DBNull"
        }

            foreach(i : int in [0..e.Row.Cells.Count-1])
            {
                when(IsCellNull(e.Row.Cells[i]))
                {
                    e.Row.Cells[i].Text="BLABLA";
                    e.Row.Cells[i].CssClass="RedColored";
                }
            }

But !!! It even doesn’t helped , it works without WHEN, but when (if) can not find empty cells 😛
Finally : solved with this code :` e.Row.Cells[0].CssClass = “wide”;

        def IsCellNull(cell : TableCell) : bool
        {
            | null => true
            | c => string.IsNullOrEmpty(c.ToString()) 
            || c.GetType().Name == "DBNull" 
            || c.Text==" "
        }

        foreach(i : int in [0..e.Row.Cells.Count-1])
        {
            when(IsCellNull(e.Row.Cells[i]))
            {
                e.Row.Cells[i].BackColor=System.Drawing.Color.Red;
            }
        }`
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T04:52:02+00:00Added an answer on May 14, 2026 at 4:52 am

    In some browsers, the cell will not display a color if it is empty. Adding a space in it solves this issue, but then it will no longer be empty…

    To test a cell, you should use string.IsNullOrEmpty():

    when(string.IsNullOrEmpty(e.Row.Cells[i].Text))
    {
      e.Row.Cells[i].Text=" "; // Or sometimes a no break space -   will work better
      e.Row.Cells[i].CssClass="RedColored";
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to detect groups which contain the difference between first age and
I'm trying to detect and remove those fields that after a sync are still
I am trying to detect when the laptop lid opens and closes, should be
I'm writing a customized view similar to Grid which will be used to hold
I need to detect where the user has just clicked from - as my
I am trying to implement the following functionality: Flex data grid has 1 default
I'm working on a game where you have an 8x12 grid where each cell
I am making a grid view. It subclasses tableview and lays out multiple subcells
I need to detect when a session has expired in my Visuial Basic web
please explain me what's wrong with following code. I am trying to detect if

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.