Index was out of range.
-
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
-
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
I think you need to change condition OrElse (index > SubTabText.Count)) Then use OrElse (index >= SubTabText.Count)) Then
Nav
-
I think you need to change condition OrElse (index > SubTabText.Count)) Then use OrElse (index >= SubTabText.Count)) Then
Nav
-
Try index > SubTabText.Count - 1 Regards, Riza Azmi Simple thing should be simple, complex thing should be possible
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