473,792 Members | 3,251 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

DropDownList SelectedValue returning "out of the range"

Here's my function:

public void getInterestLeve lDDL(string co_interest_lev el)
{
sql = [valid sql];

//get_select_list creates a valid ICollection datatable
ctrlDDL_CIL.Dat aSource = tools.get_selec t_list(sql);
ctrlDDL_CIL.Dat aTextField = "value";
ctrlDDL_CIL.Dat aValueField = "key";
try
{
ctrlDDL_CIL.Sel ectedValue = co_interest_lev el;
ctrlDDL_CIL.Dat aBind();

}
catch
{
ctrlDDL_CIL.Sel ectedValue = "0";
ctrlDDL_CIL.Dat aBind();

}

}

If co_interest_lev el is in the range of dropdownlist values, I've no
problems. However, sometimes it's not, but I can't seem to get the code
to return a default gracefully. This example fails on the second
DataBind() with the error "Specified argument was out of the range of
valid values. Parameter name: value". However, the value "0" is ALWAYS
in the list, as I've made it part of the get_select_list return value.
Also, I've tried a ClearSelection( ), but that doesn't seem to do a thing...

I'd sure appreciate any help!

--Brent
Dec 1 '05 #1
2 3145
Hi,

I dont think DataBind() call in the catch block is required.

"Brent" <"writeBrent at the google mail p" wrote:
Here's my function:

public void getInterestLeve lDDL(string co_interest_lev el)
{
sql = [valid sql];

//get_select_list creates a valid ICollection datatable
ctrlDDL_CIL.Dat aSource = tools.get_selec t_list(sql);
ctrlDDL_CIL.Dat aTextField = "value";
ctrlDDL_CIL.Dat aValueField = "key";
try
{
ctrlDDL_CIL.Sel ectedValue = co_interest_lev el;
ctrlDDL_CIL.Dat aBind();

}
catch
{
ctrlDDL_CIL.Sel ectedValue = "0";
ctrlDDL_CIL.Dat aBind();

}

}

If co_interest_lev el is in the range of dropdownlist values, I've no
problems. However, sometimes it's not, but I can't seem to get the code
to return a default gracefully. This example fails on the second
DataBind() with the error "Specified argument was out of the range of
valid values. Parameter name: value". However, the value "0" is ALWAYS
in the list, as I've made it part of the get_select_list return value.
Also, I've tried a ClearSelection( ), but that doesn't seem to do a thing...

I'd sure appreciate any help!

--Brent

Dec 1 '05 #2
Hi,

You have the DataBind incorrectly , it should be:
try
{
ctrlDDL_CIL.Dat aBind();
ctrlDDL_CIL.Sel ectedValue = co_interest_lev el;
}
And remove the DataBind in the catch block
cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Brent" <"writeBrent at the google mail place"> wrote in message
news:11******** *****@corp.supe rnews.com...
Here's my function:

public void getInterestLeve lDDL(string co_interest_lev el)
{
sql = [valid sql];

//get_select_list creates a valid ICollection datatable
ctrlDDL_CIL.Dat aSource = tools.get_selec t_list(sql);
ctrlDDL_CIL.Dat aTextField = "value";
ctrlDDL_CIL.Dat aValueField = "key";
try
{
ctrlDDL_CIL.Sel ectedValue = co_interest_lev el;
ctrlDDL_CIL.Dat aBind();

}
catch
{
ctrlDDL_CIL.Sel ectedValue = "0";
ctrlDDL_CIL.Dat aBind();

}

}

If co_interest_lev el is in the range of dropdownlist values, I've no
problems. However, sometimes it's not, but I can't seem to get the code to
return a default gracefully. This example fails on the second DataBind()
with the error "Specified argument was out of the range of valid values.
Parameter name: value". However, the value "0" is ALWAYS in the list, as
I've made it part of the get_select_list return value. Also, I've tried a
ClearSelection( ), but that doesn't seem to do a thing...

I'd sure appreciate any help!

--Brent

Dec 1 '05 #3

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

Similar topics

15
2671
by: Marc Le Roy | last post by:
Hello, ADA Ravenscar is a restricted subset of the ADA language that has been defined for real-time software development in safety critical applications. Completed with additional restrictions like the ones defined in the SPARK profile, it allow to build very deterministic applications that support automatic static code analysis and schedulability analysis. http://www.acm.org/pubs/articles/proceedings/ada/289524/p1-dobbing/p1-dobbing.pdf...
3
3478
by: Michael Conroy | last post by:
Hi... Synposis... Throws exception: "Specified argument was out of the range of valid values." Read on for the juicy tidbits. MySimpleClassCol mscc=new MySimpleClassCol(); private void InitCombo() {
1
2535
by: Clark Choi | last post by:
I ran the sample application called Petstore from msdn. Everything went fine until I tested Update button on the web form to update the database through Datagrid. I have been searching the web to track down this error, but none of them really explain this problem/solution very well. I tried hard to debug this, but debuggin itself was impossible. The error message is as follows:
2
7671
by: Lenonardo | last post by:
Hi. I'm writing a VB.Net application to update multiple Excel Worksheets. I'm using late binding (i.e. all variables are objects + use createobject) I develop the application on an XP machine with Excel 2002 (version 10.0) installed - and the code works fine. I then test the code on a laptop running Excel 2000 (version 9.0) and it
0
1098
by: H5N1 | last post by:
hi all it's extremely common scenario, so I would like to ask you how do you usually implement CRUD functionality for following structure. Basically it's all about displaying "foreign name" (ie. some textual description) instead of foreign key. GUI:
1
3268
by: tkpmep | last post by:
I write data to Excel files using PyExcelerator 0.6.3.a and have done so successfully for small files (10-15 cells). I'm experiencing an error when writing a big chunk of data (10,000 cells) to Excel. By way of comparison, the same data writes perfectly well to a csv file using Python's built in csv module. I run the program in PyScripter, and the traceback shows the following sequence of calls: main (my routine)...
8
28498
by: sam | last post by:
hey everybody, this is my first time posting here. i'm pretty new to python and programming in general (as you'll soon work out for yourselves...) i'm trying to code a version of a selection sort and the heart of the code is as follows (no_lines is simply the number of items to be sorted, read out of an input file): for j in range(0, no_lines):
3
3216
by: dvanderwel | last post by:
I have a .NET 1.1 web page with a DataGrid containing a TemplateColumn that contains a DropDownList. I need to fire an event when the selected item in the DropDownList changes for the current DataGrid row, and I'm having trouble figuring out how to do this. Other control types I have defined the "CommandName" property in the aspx file. The event returns the index of the row that contains the control, and I can thus pull more data out...
0
3435
by: CoreyReynolds | last post by:
Hey all, I have a piece of code that dumps a bunch of data into a spreadsheet. Also rearranges it into a pivot table and then graphs the pivot table as well so my boss can get a clear view of the data. This question is two part. One, I seem to be getting the title error at the starting line stating: oSheet.Range(rng).Select With Selection shp.Left = .Left shp.Top = .Top
0
9518
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10430
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10211
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10000
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7538
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6776
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5436
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4111
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3719
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.