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 8495029
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T23:27:28+00:00 2026-06-10T23:27:28+00:00

I have a VB project I’m working on where I have to break the

  • 0

I have a VB project I’m working on where I have to break the GridView down to each row and examine a specific cell. How do I go about checking to see if there is a null value or not? The following code results in the error message

“Specified argument was out of the range of valid values.
Parameter name: index”

I’ve checked the cell count for the GridViewRow variable “row” and it comes up at 5, so I’m not sure what I’m doing wrong.

Protected Sub grdProduct_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles grdProduct.RowDataBound

    ' Grey out expired products
    Dim row As GridViewRow
    row = e.Row

    Dim incomingStatus As String
    If row.Cells(5).Text.ToString() <> vbNull Then
        incomingStatus = row.Cells(5).Text.ToString()
    Else
        incomingStatus = ""
    End If

I modified the code to check the cell count first and it is still coming back with the exact same error.

    If row.Cells.Count > 5 And row.Cells(5).Text.ToString() <> vbNull Then
        incomingStatus = row.Cells(5).Text.ToString()
    Else
        incomingStatus = ""
    End If

FINAL EDIT

Modifying the code like so fixed the problem. Thanks guys:

    If row.Cells.Count > 5 Then
        If row.Cells(5).Text.ToString() <> vbNull Then
            incomingStatus = row.Cells(5).Text.ToString()
        Else
            incomingStatus = ""
        End If
    End If
  • 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-06-10T23:27:29+00:00Added an answer on June 10, 2026 at 11:27 pm

    I’ve checked the cell count for the GridViewRow variable “row” and it
    comes up at 5, so I’m not sure what I’m doing wrong.

    row.Cells(5) returns the 6th Cell, not the 5th since indices are 0 based in .NET. But the Count property returns the actual number of cells.

    The same is true for GridView.Rows.

    GridView1.Rows(9) 
    

    returns the 10th GridViewRow.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have project that concerns about calendars, at first i have 1 calendar and
We have project with a server witch have about 3000 requests at day from
I have project containing few user controls (each represents a game, but that's irrelevant),
I have project that I'm working on that is going to require a webserver.
I have project which is currently working and was developed long time back on
We have project (PHP application), but instalation for each client vary, sometimes very little,
I have project about Video on Demand via Android TV Box. I have problem,I
I have project in which user gets specific number of hours for month respective
I have project asp.net with namespace test and I'm using resources (files Resource.resx and
I have project I want to upgrade to .Net4 and it use BackgroundCopyManager.dll. Anyone

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.