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. Index was out of range.

Index was out of range.

Scheduled Pinned Locked Moved ASP.NET
helpcssdatabasetutorialquestion
4 Posts 3 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.
  • M Offline
    M Offline
    Member 3879881
    wrote on last edited by
    #1

    Hi i am getting error as: "Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index " In this error occur in user control..., In that control i have repeater control..., In that i bind some datas from my table..., In my main tab..., First one contained 4 subtabs and second one contained 2 subtabs..., Suppose if i select first main tab from that 5th subtab then if i select second main tab..., It will show this error, becoz second one have only 2 subtabs..., The pointer will refer the 4th tab in 2nd main tab..., So,its out of range..., How to show default the first subtab whenever select another maintab?, This is my code: Public Sub SelectSubTab(ByVal index As Integer) If ((index < 0) _ OrElse (index > SubTabText.Count)) Then index = 0 End If ViewState("CurrentSubTabIndex") = index BindData() Dim ev As SelectionChangedEventArgs = New SelectionChangedEventArgs ev.TabPosition = CType(ViewState("CurrentTabIndex"), Integer) ev.SubTabPosition = index RaiseEvent SelectionChanged(Me, ev) End Sub Help me...,

    Regards, Mageshh

    N 1 Reply Last reply
    0
    • M Member 3879881

      Hi i am getting error as: "Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index " In this error occur in user control..., In that control i have repeater control..., In that i bind some datas from my table..., In my main tab..., First one contained 4 subtabs and second one contained 2 subtabs..., Suppose if i select first main tab from that 5th subtab then if i select second main tab..., It will show this error, becoz second one have only 2 subtabs..., The pointer will refer the 4th tab in 2nd main tab..., So,its out of range..., How to show default the first subtab whenever select another maintab?, This is my code: Public Sub SelectSubTab(ByVal index As Integer) If ((index < 0) _ OrElse (index > SubTabText.Count)) Then index = 0 End If ViewState("CurrentSubTabIndex") = index BindData() Dim ev As SelectionChangedEventArgs = New SelectionChangedEventArgs ev.TabPosition = CType(ViewState("CurrentTabIndex"), Integer) ev.SubTabPosition = index RaiseEvent SelectionChanged(Me, ev) End Sub Help me...,

      Regards, Mageshh

      N Offline
      N Offline
      Navdeep Bhardwaj
      wrote on last edited by
      #2

      I think you need to change condition OrElse (index > SubTabText.Count)) Then use OrElse (index >= SubTabText.Count)) Then

      Nav

      R 1 Reply Last reply
      0
      • N Navdeep Bhardwaj

        I think you need to change condition OrElse (index > SubTabText.Count)) Then use OrElse (index >= SubTabText.Count)) Then

        Nav

        R Offline
        R Offline
        Riza Azmi
        wrote on last edited by
        #3

        Try index > SubTabText.Count - 1 Regards, Riza Azmi Simple thing should be simple, complex thing should be possible

        M 1 Reply Last reply
        0
        • R Riza Azmi

          Try index > SubTabText.Count - 1 Regards, Riza Azmi Simple thing should be simple, complex thing should be possible

          M Offline
          M Offline
          Member 3879881
          wrote on last edited by
          #4

          No its not working..., If its with out this statement: ViewState("CurrentSubTabIndex") = index Then it will work..., But using this above statement i am doing some other functions..., So that statement must..., So plz tell me some other solution...,

          Regards, Mageshh

          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