469,299 Members | 2,085 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,299 developers. It's quick & easy.

Specified argument was out of the range of valid values. Par

I'm getting following error in asp.net application.I search the web
and couldn't find error like this can any one help me in trouble with
this error

Specified argument was out of the range of valid values.
Parameter name: U 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: U

Source Error:
Line 120: {
Line 121: //if(val.Length > 0)
Line 122: ((ListBox)control).SelectedValue = val;
Line 123:
Line 124:
Source File: c:\inetpub\wwwroot\pplproot\careers\cfieldmapping. cs
Line: 122

Stack Trace:
[ArgumentOutOfRangeException: Specified argument was out of the range
of valid values.
Parameter name: U]
System.Web.UI.WebControls.ListControl.set_Selected Value(String
value) +152
Careers.CFieldMapping.setValue(DataRow row) in
c:\inetpub\wwwroot\pplproot\careers\cfieldmapping. cs:122
Careers.SubmitResume.loadForm(DCandidateInfo data) in
c:\inetpub\wwwroot\pplproot\careers\submitresume.a spx.cs:130
Careers.SubmitResume.Page_Load(Object sender, EventArgs e) in
c:\inetpub\wwwroot\pplproot\careers\submitresume.a spx.cs:76
System.Web.UI.Control.OnLoad(EventArgs e) +67
System.Web.UI.Control.LoadRecursive() +35
System.Web.UI.Page.ProcessRequestMain() +750

Nov 18 '05 #1
9 5583
It sounds like the value you're using does not already exist in the list of
values in the ListBox.
Nov 18 '05 #2
Hi subhar:

Your ListBox control is trying to set the selected value to val, but
val does not exist as an option in the ListBox. You need to find out
why you are setting val to an illegal value, which is something we
cannot answer looking at this bit of code.

HTH,

--
Scott
http://www.OdeToCode.com/
On 30 Sep 2004 13:03:29 -0500,
su*************@yahoo-dot-com.no-spam.invalid (subdhar) wrote:
I'm getting following error in asp.net application.I search the web
and couldn't find error like this can any one help me in trouble with
this error

Specified argument was out of the range of valid values.
Parameter name: U 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: U

Source Error:
Line 120: {
Line 121: //if(val.Length > 0)
Line 122: ((ListBox)control).SelectedValue = val;
Line 123:
Line 124:
Source File: c:\inetpub\wwwroot\pplproot\careers\cfieldmapping. cs
Line: 122

Stack Trace:
[ArgumentOutOfRangeException: Specified argument was out of the range
of valid values.
Parameter name: U]
System.Web.UI.WebControls.ListControl.set_Selected Value(String
value) +152
Careers.CFieldMapping.setValue(DataRow row) in
c:\inetpub\wwwroot\pplproot\careers\cfieldmapping .cs:122
Careers.SubmitResume.loadForm(DCandidateInfo data) in
c:\inetpub\wwwroot\pplproot\careers\submitresume. aspx.cs:130
Careers.SubmitResume.Page_Load(Object sender, EventArgs e) in
c:\inetpub\wwwroot\pplproot\careers\submitresume. aspx.cs:76
System.Web.UI.Control.OnLoad(EventArgs e) +67
System.Web.UI.Control.LoadRecursive() +35
System.Web.UI.Page.ProcessRequestMain() +750


Nov 18 '05 #3

Scott,
Below is the full code which ,where my list box is accessing the
"val" value.
//code/////

public void setValue(DataRow row)
{
String val = null;
if(row[columnName].GetType() != typeof(DBNull))
val = (string) row[columnName];
else
val = "";

if(control.GetType() == typeof(TextBox))
((TextBox)control).Text = val;
else if(control.GetType() == typeof(ListBox))
{
//if(val.Length > 0)
((ListBox)control).SelectedValue = val;
}
else if(control.GetType() == typeof(Label))
((Label)control).Text = val;
}
// code end here-------------------------
Below is the asp.net tracing
aspx.page Begin Init
aspx.page End Init 0.001449 0.001449
Unhandled Execution Error
Specified argument was out of the range of valid values.
Parameter name: U
at System.Web.UI.WebControls.ListControl.set_Selected Value(String
value)
at Careers.CFieldMapping.setValue(DataRow row) in
c:\inetpub\wwwroot\pplproot\careers\cfieldmapping. cs:line 122
at Careers.SubmitResume.loadForm(DCandidateInfo data) in
c:\inetpub\wwwroot\pplproot\careers\submitresume.a spx.cs:line 130
at Careers.SubmitResume.Page_Load(Object sender, EventArgs e) in
c:\inetpub\wwwroot\pplproot\careers\submitresume.a spx.cs:line 76
at System.Web.UI.Control.OnLoad(EventArgs e)
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Page.ProcessRequestMain() 0.161009 0.159560
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 18 '05 #4
You might want to step through the code with the debugger and see what
is in the following line of code:
val = (string) row[columnName];


It would appear this does not return a value that is in the list.
You'll need to reconcile these differences, either by adding all
possible value for that column into the list, or restricting the
values appearing in the column with your SQL query (assuming this is
coming from a database).

--
Scott
http://www.OdeToCode.com/

Nov 18 '05 #5
Hi,
I am facing similar problem, but coulnt fix the bug.
I thing its not bug in our code but in .NET Framework itself.

I am using a global function to bind the dropdownlist

code
Public Sub BindComboBox(ByRef cmb As DropDownList, ByRef sql As
String)
Dim dv As DataView
dv = GetDataView(sql)
cmb.DataValueField = dv.Table.Columns(0).ColumnName
cmb.DataTextField = dv.Table.Columns(1).ColumnName
cmb.DataSource = dv
If dv.Count > 0 Then
cmb.DataBind()
End If
End Sub

I have used this sub in some other page which is working fine. Not just
that but it worked well till last monday, But its giving me errors now,
which i am not able to fix.

In debug mode, i traced down the values, and found the query (sql) what
i am passing is returning 2 rows.

I am worried about the mistifying behaviour of .NET which with same
piece of code works some times and soemtimes doest.

Gurus..., have any clue?
========================================
==***************@yahoo.com=============
========================================
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 18 '05 #6
You say the data has 2 rows, but are you sure the result also has at
least 2 columns?
--
Scott
http://www.OdeToCode.com/blogs/scott/
On Mon, 08 Nov 2004 01:10:04 -0800, vb bomb <vb****@yahoo.com> wrote:
Hi,
I am facing similar problem, but coulnt fix the bug.
I thing its not bug in our code but in .NET Framework itself.

I am using a global function to bind the dropdownlist

code
Public Sub BindComboBox(ByRef cmb As DropDownList, ByRef sql As
String)
Dim dv As DataView
dv = GetDataView(sql)
cmb.DataValueField = dv.Table.Columns(0).ColumnName
cmb.DataTextField = dv.Table.Columns(1).ColumnName
cmb.DataSource = dv
If dv.Count > 0 Then
cmb.DataBind()
End If
End Sub

I have used this sub in some other page which is working fine. Not just
that but it worked well till last monday, But its giving me errors now,
which i am not able to fix.

In debug mode, i traced down the values, and found the query (sql) what
i am passing is returning 2 rows.

I am worried about the mistifying behaviour of .NET which with same
piece of code works some times and soemtimes doest.

Gurus..., have any clue?
========================================
===========vb****@yahoo.com=============
========================================
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!


Nov 18 '05 #7
yes, if you absorve my code I am using dv.table.colums(0).columnname

If it didnt getch the 2 columns, in my code, the very next code would
give index out of range error, isnt it?.

But after long hours I solved it.

NOW I AM ROLLING BACK MY WORDS I SAID ABOUT .NET FRAMEWORK.

It was a small mistake(no its big), which was accidently modified by me.

after finding the grid, i was suppose to select the username with the
userid which i fetched from db.
For that instread of giving combobox.selectedvalue=datafieldvalue i gave
datatextvalue

it was something like this, i have userid and username columsn fecthed
and binded combobox

in my code to select the desired user in combobox, i gave
cmbReportsTo.SelectedValue=somevalue
somevalue should be userid (but i gave username value)

thats it.

bye

========================================
===========vbbomb at yahoo dot com=============
========================================
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 18 '05 #8
Hi subdhar,

Is your problem resolved?
I thing the val at
Line 122: ((ListBox)control).SelectedValue = val
in your code is returning the DataTextField, it should match with the
DataValueField.

Bye
========================================
===========vbbomb at yahoo dot com=============
========================================
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 18 '05 #9
The default value is set as "U" as the default value in the database is
'U',Somehow .Net didn't like this string value "U".As I was debugging
someone code,I couldn't make out where this value is coming.Even if the
default value is set "U",It's giving under paramemter error.I trick the
code and make the code works.

Thanks

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 18 '05 #10

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Shakthi | last post: by
reply views Thread by rajarameshvarma | last post: by
reply views Thread by gsauns | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by harlem98 | last post: by
1 post views Thread by Geralt96 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.