Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Non-invocable member 'System.Web.UI.WebControls.ListControl.Items' cannot be used like a method error.

Non-invocable member 'System.Web.UI.WebControls.ListControl.Items' cannot be used like a method error.

Scheduled Pinned Locked Moved ASP.NET
helpdesign
4 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    Bootzilla33
    wrote on last edited by
    #1

    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.

    M Z A 3 Replies Last reply
    0
    • B Bootzilla33

      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.

      M Offline
      M Offline
      Michael_Davies
      wrote on last edited by
      #2

      Might not be the answer but you initialise I to 1 in the for loop, should it not be 0?

      1 Reply Last reply
      0
      • B Bootzilla33

        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.

        Z Offline
        Z Offline
        ZurdoDev
        wrote on last edited by
        #3

        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.

        1 Reply Last reply
        0
        • B Bootzilla33

          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.

          A Online
          A Online
          Afzaal Ahmad Zeeshan
          wrote on last edited by
          #4

          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 of bool 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 !~

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups