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

  • SEARCH
  • Home
  • 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 6835109
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T23:11:36+00:00 2026-05-26T23:11:36+00:00

I have a grid view which contains some sequence numbers. Each column needs to

  • 0

I have a grid view which contains some sequence numbers. Each column needs to have unique number sequence. It is editable and if the user input number which is already in this particular column the cells are colored in red.

So far I color only the second cell of the 2 wrong cells (with same values). How can I color both cells. As far as I know I need to use the row index as well but I have no idea how..

Here is the code

            //colum2
            string sValue2 = e.Row.Cells[4].Text;

            if (Values2.Contains(sValue2))
            {
                // This value is a duplicate - color red
                e.Row.Cells[4].BackColor = System.Drawing.Color.Red;
                 //Response.Write("Warning... Error in pad no: " +e.Row.Cells[2].Text+ " dupliated value: " +e.Row.Cells[3].Text);


            }
            else
            {
                Values2.Add(sValue2);
            }

and the same for all the 8 columns

Hopefully it’s understandable.
Thanks a lot in advance

  • 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-26T23:11:36+00:00Added an answer on May 26, 2026 at 11:11 pm

    If I get your question right, you would like to find out the RowIndex for the row which already contains the same data in the same cell, and change it’s color to red.

    You could write a method to change every cells color to red which contains that data.
    Something like:

    void colorCells(GridView GV, int CellIndex, string Text)
    {
        foreach(GridViewRow row in GV.Rows)
        {
            if(row.Cells[CellIndex].Text == Text)
                row.Cells[CellIndex].BackColor = System.Drawing.Color.Red;
            //might use else to set to default color
        }
    }
    

    And then you could use like this:

        //colum2
        string sValue2 = e.Row.Cells[4].Text;
            if (Values2.Contains(sValue2))
            {
                // This value is a duplicate - color red
                colorCells(/* Get the reference for the grid view, e.g.: gridView1*/, 4, sValue2); 
            }
            else
            {
                Values2.Add(sValue2);
            }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a grid view. Which contains some columns. Suppose, it has 10 columns
I have a GridView in which each row has a custom view. The grid
I have an image in a view which contains a 9x9 grid. I want
I have a grid view which contains 10 rows and 3 columns.. Now i
i have a grid view which contain images when click on one image it
I have user control on a ASP.NET web page, which contains a GridView and
I have a view with a grid that contains items added to a workstation.
I am trapped in one problem. I have a page which contains some taxboxes.
I have a gridview which will contain some 'n' number of rows.... Now i
I have a Gridview filled by an Adapter which returns LinearLayouts each contains an

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.