473,326 Members | 2,148 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Error filling DropdownList

Here is the DropDown:
<asp:DropDownList ID="ScreenTest" runat="server" />

Here is the code:
ScreenTest.DataSource=objCmd.ExecuteReader
ScreenTest.DataValueField="ScreenTemplateMasterID"
ScreenTest.DataTextField= "ScreenName"
ScreenTest.databind()
ScreenTest.Items.Insert(0, new ListItem("Select Screen Test",0))

Here is the error
************************************************** ************************************************** **************
Specified argument was out of the range of valid values. Parameter name:
value
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: value

Source Error:
Line 68: ScreenTest.DataValueField="ScreenTemplateMasterID"
Line 69: ScreenTest.DataTextField= "ScreenName"
Line 70: ScreenTest.databind()
<------- The error
Line 71: ScreenTest.Items.Insert(0, new ListItem("Select Screen
Test",""))
Line 72:
************************************************** ************************************************** ****************

Here is the trace of the DataReader Just before (Normally this is not there
as it would empty the reader)

ScreenName = Adminstrative Assistant
ScreenTemplateMasterID = 2
ScreenName = Network Analyst
ScreenTemplateMasterID = 1
ScreenName = Sales Clerk
ScreenTemplateMasterID = 4
ScreenName = Sales Manager
ScreenTemplateMasterID = 3

I assume the error is on the ScreenTemplateMasterID, but I don't see any
illegal values there.

What could have caused this?

Thanks,

Tom
Nov 19 '05 #1
5 1658
"tshad" <ts**********@ftsolutions.com> wrote in message
news:uW**************@TK2MSFTNGP10.phx.gbl...
Here is the DropDown:
<asp:DropDownList ID="ScreenTest" runat="server" />

Here is the code:
ScreenTest.DataSource=objCmd.ExecuteReader
ScreenTest.DataValueField="ScreenTemplateMasterID"
ScreenTest.DataTextField= "ScreenName"
ScreenTest.databind()
ScreenTest.Items.Insert(0, new ListItem("Select Screen Test",0))


Maybe you dropdown already has those values? Are you binding twice? Not
sure you would get that error or not.

Try adding this prior to your databind:
ScreenItems.Items.Clear()

Your code says this:
ScreenTest.Items.Insert(0, new ListItem("Select Screen Test",0))

But stack trace has this:
ScreenTest.Items.Insert(0, new ListItem("Select Screen Test",""))

Regardless, I would turn on Option Strict and you see that this:
ScreenTest.Items.Insert(0, new ListItem("Select Screen Test",0))

Needs to be:
ScreenTest.Items.Insert(0, new ListItem("Select Screen Test","0"))

Or maybe it really is just:
ScreenTest.Items.Insert(0, new ListItem("Select Screen Test",""))

and that was a typo. :^)

Greg
Nov 19 '05 #2

"Greg Burns" <bl*******@newsgroups.nospam> wrote in message
news:eh**************@TK2MSFTNGP09.phx.gbl...
"tshad" <ts**********@ftsolutions.com> wrote in message
news:uW**************@TK2MSFTNGP10.phx.gbl...
Here is the DropDown:
<asp:DropDownList ID="ScreenTest" runat="server" />

Here is the code:
ScreenTest.DataSource=objCmd.ExecuteReader
ScreenTest.DataValueField="ScreenTemplateMasterID"
ScreenTest.DataTextField= "ScreenName"
ScreenTest.databind()
ScreenTest.Items.Insert(0, new ListItem("Select Screen Test",0))
Maybe you dropdown already has those values? Are you binding twice? Not
sure you would get that error or not.

No.

If that were the case I would have gotten the traces twice.
Try adding this prior to your databind:
ScreenItems.Items.Clear()
I tried that.

Didn't change anything.
Your code says this:
ScreenTest.Items.Insert(0, new ListItem("Select Screen Test",0))

But stack trace has this:
ScreenTest.Items.Insert(0, new ListItem("Select Screen Test",""))

Regardless, I would turn on Option Strict and you see that this:
ScreenTest.Items.Insert(0, new ListItem("Select Screen Test",0))

Needs to be:
ScreenTest.Items.Insert(0, new ListItem("Select Screen Test","0"))

Or maybe it really is just:
ScreenTest.Items.Insert(0, new ListItem("Select Screen Test",""))

and that was a typo. :^)

I had copied the error already and did a couple of other tests to see if I
could narrow it down. That was why that line was different. Actually, the
Double-Quotes is how I originally had it.

I also thought that maybe I had accidently created another object with that
name, but that wasn't the case either.

I took the SP and tried run it from Query Analyser and got the same results
as my trace.

ScreenTemplateMasterID ScreenName
---------------------- --------------------------------------------------
2 Adminstrative Assistant
1 Network Analyst
4 Sales Clerk
3 Sales Manager

(4 row(s) affected)

This doesn't make any sense.

It was working fine before.

Thanks,

Tom Greg

Nov 19 '05 #3
Hi tshad,

When you DataBind the dropdown, it trys to reset itself to its previously
selected value.
Call ClearSelection() on it before you bind it.

Tim

"tshad" wrote:
Here is the DropDown:
<asp:DropDownList ID="ScreenTest" runat="server" />

Here is the code:
ScreenTest.DataSource=objCmd.ExecuteReader
ScreenTest.DataValueField="ScreenTemplateMasterID"
ScreenTest.DataTextField= "ScreenName"
ScreenTest.databind()
ScreenTest.Items.Insert(0, new ListItem("Select Screen Test",0))

Here is the error
************************************************** ************************************************** **************
Specified argument was out of the range of valid values. Parameter name:
value
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: value

Source Error:
Line 68: ScreenTest.DataValueField="ScreenTemplateMasterID"
Line 69: ScreenTest.DataTextField= "ScreenName"
Line 70: ScreenTest.databind()
<------- The error
Line 71: ScreenTest.Items.Insert(0, new ListItem("Select Screen
Test",""))
Line 72:
************************************************** ************************************************** ****************

Here is the trace of the DataReader Just before (Normally this is not there
as it would empty the reader)

ScreenName = Adminstrative Assistant
ScreenTemplateMasterID = 2
ScreenName = Network Analyst
ScreenTemplateMasterID = 1
ScreenName = Sales Clerk
ScreenTemplateMasterID = 4
ScreenName = Sales Manager
ScreenTemplateMasterID = 3

I assume the error is on the ScreenTemplateMasterID, but I don't see any
illegal values there.

What could have caused this?

Thanks,

Tom

Nov 19 '05 #4
"timkling" <ti******@discussions.microsoft.com> wrote in message
news:F1**********************************@microsof t.com...
Hi tshad,

When you DataBind the dropdown, it trys to reset itself to its previously
selected value.
Call ClearSelection() on it before you bind it.
Is that different than ScreenTest.Items.Clear()?

Thanks,

Tim

"tshad" wrote:
Here is the DropDown:
<asp:DropDownList ID="ScreenTest" runat="server" />

Here is the code:
ScreenTest.DataSource=objCmd.ExecuteReader
ScreenTest.DataValueField="ScreenTemplateMasterID"
ScreenTest.DataTextField= "ScreenName"
ScreenTest.databind()
ScreenTest.Items.Insert(0, new ListItem("Select Screen Test",0))

Here is the error
************************************************** ************************************************** **************
Specified argument was out of the range of valid values. Parameter name:
value
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: value

Source Error:
Line 68: ScreenTest.DataValueField="ScreenTemplateMasterID"
Line 69: ScreenTest.DataTextField= "ScreenName"
Line 70: ScreenTest.databind()
<------- The error
Line 71: ScreenTest.Items.Insert(0, new ListItem("Select Screen
Test",""))
Line 72:
************************************************** ************************************************** ****************

Here is the trace of the DataReader Just before (Normally this is not
there
as it would empty the reader)

ScreenName = Adminstrative Assistant
ScreenTemplateMasterID = 2
ScreenName = Network Analyst
ScreenTemplateMasterID = 1
ScreenName = Sales Clerk
ScreenTemplateMasterID = 4
ScreenName = Sales Manager
ScreenTemplateMasterID = 3

I assume the error is on the ScreenTemplateMasterID, but I don't see any
illegal values there.

What could have caused this?

Thanks,

Tom

Nov 19 '05 #5
Yeah, it is different.

Whether you clear the Items collection, or you just call DataBind() (which
clears the collection for you first anyway), the dropdown "remembers" what
the selected value is. When you rebind it, it tries to select an item with
the same value, if there is none, it throws an exception. Calling
ClearSelection(), explicitly clears any selected value, so that it will not
try to reset the selected item while DataBinding.

Tim
"tshad" wrote:
"timkling" <ti******@discussions.microsoft.com> wrote in message
news:F1**********************************@microsof t.com...
Hi tshad,

When you DataBind the dropdown, it trys to reset itself to its previously
selected value.
Call ClearSelection() on it before you bind it.


Is that different than ScreenTest.Items.Clear()?

Thanks,

Tim

"tshad" wrote:
Here is the DropDown:
<asp:DropDownList ID="ScreenTest" runat="server" />

Here is the code:
ScreenTest.DataSource=objCmd.ExecuteReader
ScreenTest.DataValueField="ScreenTemplateMasterID"
ScreenTest.DataTextField= "ScreenName"
ScreenTest.databind()
ScreenTest.Items.Insert(0, new ListItem("Select Screen Test",0))

Here is the error
************************************************** ************************************************** **************
Specified argument was out of the range of valid values. Parameter name:
value
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: value

Source Error:
Line 68: ScreenTest.DataValueField="ScreenTemplateMasterID"
Line 69: ScreenTest.DataTextField= "ScreenName"
Line 70: ScreenTest.databind()
<------- The error
Line 71: ScreenTest.Items.Insert(0, new ListItem("Select Screen
Test",""))
Line 72:
************************************************** ************************************************** ****************

Here is the trace of the DataReader Just before (Normally this is not
there
as it would empty the reader)

ScreenName = Adminstrative Assistant
ScreenTemplateMasterID = 2
ScreenName = Network Analyst
ScreenTemplateMasterID = 1
ScreenName = Sales Clerk
ScreenTemplateMasterID = 4
ScreenName = Sales Manager
ScreenTemplateMasterID = 3

I assume the error is on the ScreenTemplateMasterID, but I don't see any
illegal values there.

What could have caused this?

Thanks,

Tom


Nov 19 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: reidarT | last post by:
I am filling a combobox with data from a table. This is done with the code below. After update of the combobox I want to fill txtField2 with data from Field2 in the select-statement. How can I do...
6
by: Teep | last post by:
Below is my code for dropdownlist that is populated from a SQL table. After a selection from the ddl, a datagrid is suppose to come up pertaining to the information selected, but I keep getting a...
3
by: Sean | last post by:
HI There, I am trying to submit a form when a selection is made from a dropdown list, I keep getting the error "Handles clause requires With Events Variable". Could someone help me with the...
6
by: blash | last post by:
Can someone help me? I really don't have a clue. My company staff told me they often got such error: "Object reference not set to an instance of an object." when they are in search result page...
1
by: Luis Esteban Valencia | last post by:
Compilation Error Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source...
2
by: Joris De Groote | last post by:
Hi, I have a dropdownlist that contains should contain several values from the database, I fill it up in de page_load() with this code (at the end of the message) The code also adds a...
4
by: ITCraze | last post by:
Hello everyone, I have three tables CompanyMst ,BranchMst and DeptMst. CompanyMst contains: CompanyId(Primary Key) ,CompanyName. BranchMst contains: CompanyId(Foreign...
10
by: Roger | last post by:
ms-access97 & sql server2005 two tables tblItem tblItemFeature form frmItem contains subform frmItemFeature each form is based on their respective table creating new record and filling in...
6
by: Ahmedhussain | last post by:
Hi there, I m doing work on a gridview and Im getting an error: A potentially dangerous Request.Form value was detected from the client (ctl00$Content$GridView1$ctl03$TextBox1="<span...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.