Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Specified argument was out of the range of valid values. Parameter name: index

Posted on 2005-04-08
8
Medium Priority
?
639 Views
Last Modified: 2008-02-01
Hi,

Please kindly help me resolved this error,

Dim txtDescription As TextBox = DirectCast(e.Item.Cells(1).Controls(0),TextBox)
Specified argument was out of the range of valid values. Parameter name: index

Thanks.

Server Error in '/' Application.
--------------------------------------------------------------------------------
Specified argument was out of the range of valid values. Parameter name: index
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values. Parameter name: index
Source Error:
Line 118:                            Sub manage_update( s As Object, e As DataGridCommandEventArgs)
Line 119:                                Dim key As String= DataGrid1.DataKeys.Item(DataGrid1.EditItemIndex)
Line 120:                                Dim txtDescription As TextBox = DirectCast(e.Item.Cells(1).Controls(0),TextBox)
Line 121:                                Dim ddlteam As DropDownList = DirectCast(e.Item.Cells(2).FindControl("DropDownList1"),DropDownList)
Line 122:                                Dim ddldesignation As DropDownList = DirectCast(e.Item.Cells(3).FindControl("DropDownList2"),DropDownList)
 

Source File: c:\inetpub\wwwroot\shiftview.aspx    Line: 120
0
Comment
Question by:lynnton
  • 4
  • 3
8 Comments
 
LVL 9

Accepted Solution

by:
Type25 earned 2000 total points
ID: 13734627
Change line 120 to:

Dim txtDescription As TextBox = DirectCast(e.Item.Cells(1).Controls(1),TextBox)
0
 
LVL 1

Author Comment

by:lynnton
ID: 13734648
Type25,

Sadly same error message.

Please let me know if you need more information and on which part.

Thanks.
0
 
LVL 1

Author Comment

by:lynnton
ID: 13734656
Type25,

I think i may have something.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 9

Expert Comment

by:Type25
ID: 13734691
I'm guessing here as i don't know what index relates to what...

could try:

Dim txtDescription As TextBox = DirectCast(e.Item.Cells(0).Controls(1),TextBox)

It will always be .Controls(1)    as opposed to Controls(0)

0
 
LVL 1

Author Comment

by:lynnton
ID: 13734795
Type25,

it was a typo error on the store procedure, unfortunately this new error came up, is it fine with you to help me ?

Thanks.



                        Sub Manage_ItemDataBound(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs)
                                SetDeletionAlert(e.Item)
                                If e.Item.ItemType = ListItemType.EditItem Then
                                Dim DDL1 as DropDownList = e.Item.FindControl("DropDownList1")
                                DDL1.DataSource=GenerateSourcestarttime().defaultview
                                DDL1.DataTextField="starttime"
                                DDL1.DataValueField="shiftid"
                                DDL1.Items.Insert(0, "Select")
                                DDL1.DataBind()

                                Dim lbl1 as Label = e.Item.FindControl("lblSelected1")
                                Dim strSelected1 = CStr(lbl1.Text)
                                Dim i1 As ListItem = DDL1.Items.FindByText(strSelected1)
                                If strSelected1 <> "" Then
                                DDL1.Items.FindByText(strSelected1).Selected=true
                                else
                                DDL1.Items.Insert(0, "Select")
                                end if
                                End If
                        End Sub






Server Error in '/' Application.
--------------------------------------------------------------------------------

Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
Source Error:
Line 199:                                Dim i1 As ListItem = DDL1.Items.FindByText(strSelected1)
Line 200:                                If strSelected1 <> "" Then
Line 201:                                DDL1.Items.FindByText(strSelected1).Selected=true
Line 202:                                else
Line 203:                                DDL1.Items.Insert(0, "Select")
 

Source File: c:\inetpub\wwwroot\shiftview.aspx    Line: 201

Stack Trace:

0
 
LVL 9

Expert Comment

by:Type25
ID: 13734936
Hmm...   DDL1.Items.FindByText(strSelected1).Selected=true      

strSelected1  cannot be found in the DDL1 List.

You might try:
DDL1.Items.FindByValue(strSelected1).Selected=true

?
0
 
LVL 1

Author Comment

by:lynnton
ID: 13734957
Type25,

Same thing, how can we troubleshoot ?

Thanks,
0
 
LVL 6

Expert Comment

by:Maulik Modi
ID: 13738550
Can you try with following code:

Dim dv as DataView = GenerateSourcestarttime().defaultview

     If  dv.Rows.Count > 0
                 DDL1.DataSource=dv
                  DDL1.DataTextField="starttime"
                   DDL1.DataValueField="shiftid"
                   DDL1.DataBind()
                   DDL1.Items.Insert(0, "Select")

                   Dim lbl1 as Label = e.Item.FindControl("lblSelected1")
                   Dim strSelected1 = CStr(lbl1.Text)

                    If strSelected1 <> "" Then
                             DDL1.Items.FindByText(strSelected1).Selected=true
                    else
                            DDL1.Items(0).Selected = true
                    end if            
        End If

Cheers!!!
MaulikCE
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on www.johnchapman.name could not pull conte…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question