Use addrange with datagrid item.cell

Posted on 2009-02-13
Last Modified: 2012-08-13
What I have is a datagrid with 7 columns in it.  Currently I have it so that if there is a no in cell 7 it colors the name red.  What I really need is a way to call out columns 2 -7 if there are any no's it colors the name red.  I have tried using the following with no luck keeps giving me blue underlines ander the range numbers.  How can I call our columns 2 - 7 and color name red if they have a no.

If e.Item.ItemType = ListItemType.Item OrElse e.Item.ItemType = ListItemType.AlternatingItem Then

            If e.Item.Cells.AddRange(2 - 7).Text = "No" Then

                e.Item.Cells(0).BackColor = System.Drawing.Color.Tomato

            End If

            If e.Item.Cells(7).Text = "Yes" Then

                e.Item.Cells(0).BackColor = System.Drawing.Color.Green

            End If

        End If

Open in new window

Question by:kdeutsch
    1 Comment
    LVL 16

    Accepted Solution

    add range only adds cells, you need to loop through the cells to do that

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Free Trending Threat Insights Every Day

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
    A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
    It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    8 Experts available now in Live!

    Get 1:1 Help Now