Click here to Skip to main content
15,892,809 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello,
I'm getting the error below in a grid. Not as a run-time error, in fact there's no error displayed at all. The only way I know about it is because I investigated why I wasn't getting the desired result my code should have produced.

"Error - In order to evaluate an indexed property, the property must be qualified and the arguments must be explicitly supplied by the user."

Specifically, what I'm trying to do is change the color of a cell, of a grid row, which contains an error, during the binding event, so the user sees where the error lies.

VB
Private Sub ValidateGridRow(row As GridViewRow)
    Dim dateValue As Date
    'Gender...
    If Not row.Cells(5).Text.Trim() = "M" Or
         Not row.Cells(5).Text.Trim() = "F" Then
        row.Cells(5).BackColor = Drawing.Color.PaleVioletRed
        bGridValid = False
    End If
    If row.Cells(5).Text.Trim() = "" Then
        row.Cells(5).BackColor = Drawing.Color.PaleVioletRed
        bGridValid = False
    End If
    'Zip code...
    If row.Cells(10).Text.Trim() = "" Or
        row.Cells(10).Text.Trim().Length < 5 Then
        row.Cells(10).BackColor = Drawing.Color.PaleVioletRed
        bGridValid = False
    End If
    If Not IsNumeric(row.Cells(10).Text.Trim()) Then
        row.Cells(10).BackColor = Drawing.Color.PaleVioletRed
        bGridValid = False
    End If
    'DOB...
    If Not Date.TryParse(row.Cells(6).Text, dateValue) Then
        row.Cells(6).BackColor = Drawing.Color.PaleVioletRed
        bGridValid = False
    End If

End Sub


What I have tried:

I've read other posts across the web regarding this issue but the majority were in C# and that's not my forte and the others had other things going on I didn't understand. I'm a newbie so I need a little help please.

Thanks in advance for your time and help.
Red
Posted
Updated 12-Apr-16 23:06pm
Comments
Sergey Alexandrovich Kryukov 12-Apr-16 19:04pm    
1) "I'm getting the error below in a grid".
2) "...in fact there's no error displayed at all".
3) "Error - In order to evaluate an indexed property, the property must be qualified and the arguments must be explicitly supplied by the user."

Can you see some apparent contradictions?
You ether don't understand what really happened or failed to explain it. :-)

Do you know what is "indexed property" and how to use it? If not, simply read on this topic, without any relation to your code. When you read and understand it, you will see that this problem simply does not exist, and only then you will fix your code. (You did not show in what line there is a problem anyway.)

—SA
Redvan 13-Apr-16 10:13am    
Hey Sergey,
Did you ever read this:

When answering a question please:
1.Read the question carefully.
2.Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
3.If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
Let's work to help developers, not make them feel stupid.

Thanks for the insult...

1 solution

You just missing. This command will apply the changes. It is my assumption that you are trying to update the GridView after page load. Following command will update Gridview and apply the changes you have made before this command. this statement should appear at the end of your formatting code and before End Sub.

Me.GridView.Update()


One more suggestion Switch statement is more suitable for your current scenario.

It will help you.
Cheers
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900