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

I have two drop down list, one are titles, second one are title definition.
after clicking titles dropdown list, second one will show the definition.
it works fine when I used code below in the function BindData_Type_dropdown()

type_DropDownList.DataSource = ds.Tables(0)
        'type_DropDownList.DataTextField = ds.Tables(0).Columns("Title").ColumnName.ToString()
        'type_DropDownList.DataValueField = ds.Tables(0).Columns("ID").ColumnName.ToString()
        'type_DropDownList.DataBind()

after changing the code to

dreaderEn = En_cmd.ExecuteReader()

        While dreaderEn.Read()
            Dim newListItem1 As New ListItem
            newListItem1.Text = dreaderEn.GetString(1)
            newListItem1.Value = dreaderEn.GetInt32(0)
            type_DropDownList.Items.Add(newListItem1)

        End While

I get a error message when clicking last record in the dropdown list. error message is
"Specified argument was out of the range of valid values. Parameter name: value ".
it only got error message when I clicking last record. the rest of record work fine

all code below

        Sub BindData_Type_dropdown()

        Dim dreaderEn As SqlDataReader

        Dim En_con As New SqlConnection(ConfigurationSettings.GetConfig("AppSettings")("Connection"))

        En_con.Open()

        Dim En_cmd As New SqlCommand("asp_dd_Type", En_con)

        En_cmd.CommandType = CommandType.StoredProcedure
        Dim prmE_number As New SqlParameter

        prmE_number.ParameterName = "@ID"
        prmE_number.SqlDbType = SqlDbType.Int
        prmE_number.Value = myID

        prmE_number.Size = 4
        En_cmd.Parameters.Add(prmE_number)
        Dim myda As SqlDataAdapter
        Dim ds As DataSet
        myda = New SqlDataAdapter
        myda.SelectCommand = En_cmd

        ds = New DataSet
        myda.Fill(ds)
        'type_DropDownList.DataSource = ds.Tables(0)
        'type_DropDownList.DataTextField = ds.Tables(0).Columns("Title").ColumnName.ToString()
        'type_DropDownList.DataValueField = ds.Tables(0).Columns("ID").ColumnName.ToString()
        'type_DropDownList.DataBind()

        dreaderEn = En_cmd.ExecuteReader()

        While dreaderEn.Read()
            Dim newListItem1 As New ListItem
            newListItem1.Text = dreaderEn.GetString(1)
            newListItem1.Value = dreaderEn.GetInt32(0)
            type_DropDownList.Items.Add(newListItem1)

        End While

        ddl_Defs.EnableViewState = True
        ddl_Defs.DataSource = ds.Tables(0)
        ddl_Defs.DataTextField = ds.Tables(0).Columns("Def").ColumnName.ToString()
        ddl_Defs.DataValueField = ds.Tables(0).Columns("ID").ColumnName.ToString()
        ddl_Defs.DataBind()

        ddl_Defs.SelectedIndex = type_DropDownList.SelectedIndex
        DefinitionContent.Text = ddl_Defs.SelectedItem.Text

        En_con.Close()

    End Sub


Public Sub type_DropDownList_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles type_DropDownList.SelectedIndexChanged
        ddl_Defs.SelectedIndex = type_DropDownList.SelectedIndex
        ddl_Defs.SelectedItem.Selected = True
        DefinitionContent.Text = ddl_Defs.SelectedItem.Text
        GetFormat()
    End Sub

aspx code

    <asp:DropDownList id="type_DropDownList" runat="server" Width="592px" Height="24px" OnSelectedIndexChanged="type_DropDownList_SelectedIndexChanged"
                EnableViewState="True"  AutoPostBack="True">
             <asp:ListItem  Value=0 Selected="True">--Select Covenant--</asp:ListItem>
    </asp:DropDownList></TD>
    <asp:DropDownList id="ddl_Defs" runat="server" Width="24px" Visible="False"></asp:DropDownList>

 

1)error message in function Public Sub type_DropDownList_SelectedIndexChanged
in line
ddl_Defs.SelectedIndex = type_DropDownList.SelectedIndex

2)why I want to use ListItem , because I want to set dropdown list default is "select type". not value. <asp:ListItem  Value=0 Selected="True">--Select Covenant--</asp:ListItem>

I found the problem is dropdown list ddl_Defs which was out of the range of valid values. but I don't know how to fix that.

0
hong_ma
10/3/2005 1:04:36 PM
asp.net.web-forms 93655 articles. 4 followers. Follow

2 Replies
2088 Views

Similar Articles

[PageSpeed] 26

Hmmm, try instead:

            newListItem1.Text = dreaderEn("Title")
            newListItem1.Value = dreaderEn("ID")

Marcie
http://www.datagridgirl.com
NEW! http://www.gridviewgirl.com
0
datagridgirl
10/3/2005 3:53:45 PM

Thanks, got same error message after changing the code to your code.  

0
hong_ma
10/3/2005 4:19:46 PM
Reply:

Similar Artilces:

specified argument was out of the range of valid values parameter name: value
 hello everyone, i need your help.. i have a gridview that has a delete button, this gridview is inside a parent gridview. my problem now is when i delete the row(the child griview will always contain one row only)  it gave me an error stating that the specified argument was out of range of valid values parameter name: value, after refreshing that's the only time the delete button will function correctly. what could be the possible reason for this, this error appears occasionally, i can't afford to have this error during our defense..please help....here is my code for delet...

Specified argument was out of range of valid values. Parameter name:Value
Hi Guru's,  Below is my problem. I have a user control, in which I have a ajax tab control. At design time I just have the tabcontainer and depending on the id passed to the control I am generating the contents for the tab's. Basically each of the tab contains a list of items for each item a series of option buttons are presented to mark the score.  I have set eanable view state to false for tab and all the dynamically generated radio buttons and checkbox's, and enabled autopostback to ture, when I click on any of radio button, checkbox or image b...

(Urgent) specified argument was out of the range of valid values. Parameter name: Value
Hi  i have a datagrid in a user control which has pagin and sorting enabled and the data loads fine.. I am calling this UserControl in a tab panel using Ajax.. But when I Try to sort and page in my tab Panel...i get an error saying  specified argument was out of the range of valid values. Parameter name: Value Hope u can help me solve it.. I am dynamically generating the Tabpanel and passing the valid values to load the user control.. but when i try to page and sort i get a popup with the above error.. Any help will be appreicated. Regards Karen Golden rule about ...

Error:
Can anyone help me, I am getting the following error whilst attempting to retrieve data from an Access DB: Specified argument was out of the range of valid values. Parameter name: value I receive this error from a method which uses a select statement to retrieve data into a datareader, and then I place the value of each of the columns into variables. I have another method before this one which is identical, except for the select statement, and it gives me no errors at all. Here is my code: 'create the connection string objects Dim connstr As String co...

critical error has occurred.Specified argument was out of the range of valid values. Parameter name: value
In Debug mode my cutome module is working well. After that i created a zip file to upload the module and also i deleted my tables and store procedures.When I upload my zip file there is no error, Table and All the storeprocedures are installed  in my database.I don't know what is the problem.The error message is this The problem could be that you did not set valid default values for you module settings.Have a look at this.Best regardsHans-PeterDNNPortal German DotNetNuke Community Thank you very muchI reolve that problem by setting the default settings.Now i have one more probl...

(urgent) How do i handle this error in tabs: ( specified argument was out of the range of valid values. Parameter name: Value)
Hi   My user control consisted of a datagrid and in that datagrid i was diplaying the plans for that particular user.. My user control consits of paging and sorting but when i click on those pages no and sort by column name i get and error in the form of an popup window but the pagin and the sorting is been handled by the User control...  specified argument was out of the range of valid values. Parameter name: Value   What should i do to solve it Regards KAren...

Specified argument was out of the range of valid values. Parameter name: Hour, Minute, and Second parameters describe an unrepresentable DateTime.
This error frequently occurs when run OleDbCommand.ExecuteReader to query data from Oracle database and then bind to the DataGrid. In sql select statement has no any datatype date column. I use Oracle Provider for OLE DB. Check out my post on storing dates in Oracle at http://www.asp.net/Forums/ShowPost.aspx?tabindex=1&PostID=341221...

Error adding node
 I have a recordset that I loop thru adding nodes to my treeview.Well at around record # 123 out of 500 or so, I get this error adding child node :"Specified argument was out of the range of valid values.Parameter name: Index was out of range.  Must be non-negative and less than the size of the collection." The node I'm adding to exists, and I can't see anything wrong w/ the data -  and it always gets hung up on the same record.*And the same code has been used 122 times already w/out issue. *Any ideas ?  my code: 'lastDivisionIndex = 1'...

Specified argument was out of the range of valid values. Parameter name: 3
  Specified argument was out of the range of valid values. Parameter name: 3 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: 3Source Error: Line 227: Line 228: If l_cnt = 0 Then Line 229: ddlCourse.SelectedValue = p_rsBatach("courseID").Value Line 230: txtBatchC...

Specified argument was out of the range of valid values.Parameter name: index ?
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: indexSource Error: Line 146: Line 147: Line 148: Dim temp_members = "INSERT INTO T_EGIS_INT_MOTOR_MST " & _ Line 149: "(PRODUCT_CODE, MAKE, &qu...

Specified argument was out of the range of valid values Parameter name: index
i'm having a weird problem that isn't reproducing itself on any of my other pages. i need to run an if/else in page_load, the if statement is the text value of a label in a datalist (if the label is null do this, if it's not do that) - my datalist and sqldatasource code looks like this:  <asp:DataList ID="DataList1" runat="server" DataSourceID="iplist"> <ItemTemplate> ip: <asp:Label ID="ipLabel" runat="server" Text='<%# Eval("ip&...

Specified argument was out of the range of valid values. Parameter name: options
when i  try running a  webform i got this error:Specified argument was out of the range of valid values. Parameter name: optionsi dont where the error originated since i didnt put any control on the page i just run a plain webform.. but during the page load the error occured..any help with thi??...thnks in advance guy i keep on  posting this thread but  no reply even one. Need to see the code....Zath i didnt wrote any code just a plain webform no control or whatever the stack trace error is this:  Server Error in '/first' Application. Specified argument wa...

Specified argument was out of the range of valid values. Parameter name: index
This is the error I'm getting. I will paste my code below: " DeleteCommand="DELETE FROM [Friends] WHERE [FriendName] = @FriendName" SelectCommand="SELECT * FROM [Friends] WHERE (([FriendName] = @FriendName))" UpdateCommand="UPDATE [Friends] SET [UserName] = @UserName, [UserID] = @UserID, [IP] = @IP, [AddedOn] = @AddedOn, [FriendName] = @FriendName, [IsApproved] = @IsApproved WHERE [FriendID] = @FriendID"> ...

Web resources about - Specified argument was out of the range of valid values. Parameter name: value - asp.net.web-forms

Michael Galeota Dies: Star Of Disney Channel’s ‘The Jersey’ Was 31
Michael Galeota , who starred as a teenager on Disney Channel ’s series The Jersey and CBS’ Bailey Kipper’s P.O.V. , died Sunday. He was 31. ...

Multi-User Support For iPads Finally Arrives On iOS 9.3
The idea that a smart device like a phone or tablet that supports more than one user isn’t that much of a stretch. In fact, in the past, we have ...

Audi's h-tron quattro concept makes hydrogen fuel cells stylish
DETROIT — Audi surprised attendees of the North American International Auto Show with a new hydrogen fuel cell-powered concept called the "h-tron ...

Kim Davis Is Going to the State of the Union
Kim Davis will be attending the State of the Union. Yes, that same Kim Davis who rose to national prominence after she refused to issue marriage ...

Powerball math mistake fires up the Internet as $1.4 billion drawing nears
The math behind this week’s upcoming $1.4 billion Powerball drawing boggles the mind, but at least a few minds were boggled beyond the bounds ...

New Jersey Dad Charged With Murder in 3-Year-Old Boy's Death
Father of 3-year-old boy found dead in New Jersey park last year is charged with his murder

Ansel Elgort Being Considered For Star Of Han Solo Spin-Off — Who Else Is Up For The Part?
The co-writer of Star Wars: The Force Awakens Lawrence Kasdan is reportedly working on a Han Solo spin-off movie, featuring the iconic character ...

Recharge Wrap-up: Tesla Autopilot limitations test, Gigafactory in S. Africa?
Filed under: Government/Legal , Green , Plants/Manufacturing , Tesla , Alternative Fuels , Biodiesel , Autonomous , Electric Tesla's Autopilot ...

Supreme Court Hears Case That Could Deal Blow to Unions
A Supreme Court case argued Monday could significantly weaken government unions across the country. If the justices rule in favor of the plaintiffs ...

Our Top Picks of CES 2016
No slowing down for the world’s largest technology expo — one week and more than 170,000 people later, CES 2016 has passed leaving far more tech ...

Resources last updated: 1/12/2016 12:58:19 AM