ObjectDataSource SelectParameter and Nullable type

S

Steve B.

Hi,

On a page, I've a dropdownlist box that is bound to an object datasource
(which is a proxy to a web service).
I also have a gridview that is bound to another object datasource (a ws
too). The select method of this datasource has an argument which is type of
int? (Nullable<Int32>).

I want to set the select parameter value to the dropdown list value which
can be either any int or null.
I set up the drop down list to add one item : None with no value and other
items are from the object data source.

When I select any of the item in the DDL, the correct int value is send to
the select parameter.
However, when I select the manually added item with no value, this throw an
exception "Input string was not in correct format"... the control seems to
execute an Int.Parse(null) which throws the exception.

I found a workaround which is to set the None item's value to -1, but I need
to update the service to understant the -1 value like a null value... and
it's not a clean "3-tiers" solution.

How can I correctly reach my behaviour ?

Thanks in adcance,
Steve
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top