Non-invocable member 'System.Web.UI.WebControls.ListControl.Items' cannot be used like a method error.
-
Getting error on bolded line, activitycode.Item(I),Value... if you can't see it.
private void cvactivitycode_ServerValidate(object source, ServerValidateEventArgs args)
{
args.IsValid = false;
for (short I = 1; (I
<= (activitycode.Items.Count - 1)); I++)
{
if (activitycode.Items(I).Value)
{
args.IsValid = true;
break;
}} }
What am I missing or need to fix.
-
Getting error on bolded line, activitycode.Item(I),Value... if you can't see it.
private void cvactivitycode_ServerValidate(object source, ServerValidateEventArgs args)
{
args.IsValid = false;
for (short I = 1; (I
<= (activitycode.Items.Count - 1)); I++)
{
if (activitycode.Items(I).Value)
{
args.IsValid = true;
break;
}} }
What am I missing or need to fix.
Might not be the answer but you initialise I to 1 in the for loop, should it not be 0?
-
Getting error on bolded line, activitycode.Item(I),Value... if you can't see it.
private void cvactivitycode_ServerValidate(object source, ServerValidateEventArgs args)
{
args.IsValid = false;
for (short I = 1; (I
<= (activitycode.Items.Count - 1)); I++)
{
if (activitycode.Items(I).Value)
{
args.IsValid = true;
break;
}} }
What am I missing or need to fix.
The error says you cannot use Items like a method. You used () instead of []. So, change Items(I) to Items[I]. You are not calling the method Items() you are accessing an item in the collection.
There are two kinds of people in the world: those who can extrapolate from incomplete data. There are only 10 types of people in the world, those who understand binary and those who don't.
-
Getting error on bolded line, activitycode.Item(I),Value... if you can't see it.
private void cvactivitycode_ServerValidate(object source, ServerValidateEventArgs args)
{
args.IsValid = false;
for (short I = 1; (I
<= (activitycode.Items.Count - 1)); I++)
{
if (activitycode.Items(I).Value)
{
args.IsValid = true;
break;
}} }
What am I missing or need to fix.
Seems like you are aware of VB.NET.
if (activitycode.Items(I).Value)
That is VB.NET way of accessing array elements, in C# that is used to invoke functions. What you need is like this,
if (activitycode.Items[I].Value)
This would work — provided no other errors are raised; is
Value
ofbool
type?. For more on this, you can just search for, "array indexing in c# vs vb.net", and also "how to call functions in c#" they will give you a good overview of these features.The shit I complain about It's like there ain't a cloud in the sky and it's raining out - Eminem ~! Firewall !~