Hello,

Have an objectdatasource with a method much like this:

public SomeDataSet.MyDataTable getMyDataTable(int? pkID)
{
if (pkID == null)
return adapater.GetMyTable("ALL")
else
return adapter.GetMyTable("SING")
}

When I configure the objectdatasource I tell it to call this method
for the select. In the define parameters if I give it a value of 1, or
2, or some other integer works fine. If I tell it to use null as the
default value, at run time I get an error "Input string was not in
correct format". Any ideas anyone?

Thanks

Ray

Re: ObjectDataSource - Select - Nullable parameter by rbrowning1958

rbrowning1958
Wed May 07 12:39:38 CDT 2008

On May 7, 6:16=A0pm, rbrowning1958 <RBrowning1...@gmail.com> wrote:
> Hello,
>
> Have an objectdatasource with a method much like this:
>
> public SomeDataSet.MyDataTable getMyDataTable(int? pkID)
> {
> =A0 if (pkID =3D=3D null)
> =A0 =A0 =A0return adapater.GetMyTable("ALL")
> =A0 else
> =A0 =A0 =A0return adapter.GetMyTable("SING")
>
> }
>
> When I configure the objectdatasource I tell it to call this method
> for the select. In the define parameters if I give it a value of 1, or
> 2, or some other integer works fine. If I tell it to use null as the
> default value, at run time I get an error "Input string was not in
> correct format". Any ideas anyone?
>
> Thanks
>
> Ray

For anyone interested I solved this. You just leave the parameter
empty - don't try typing in null doh!

Ray

Re: ObjectDataSource - Select - Nullable parameter by Lloyd

Lloyd
Wed May 07 13:00:47 CDT 2008


"rbrowning1958" <RBrowning1958@gmail.com> wrote in message
news:6b42e885-a03b-47af-9ad7-519223e49598@b64g2000hsa.googlegroups.com...
> Hello,
>
> Have an objectdatasource with a method much like this:
>
> public SomeDataSet.MyDataTable getMyDataTable(int? pkID)
> {
> if (pkID == null)
> return adapater.GetMyTable("ALL")
> else
> return adapter.GetMyTable("SING")
> }
>
> When I configure the objectdatasource I tell it to call this method
> for the select. In the define parameters if I give it a value of 1, or
> 2, or some other integer works fine. If I tell it to use null as the
> default value, at run time I get an error "Input string was not in
> correct format". Any ideas anyone?
>
> Thanks
>
> Ray

If I may make a suggestion. Create an enum with each value for GetMyTable
and then use a switch statement to do the correct GetMyTable. In case you
have to get another table this would be much more flexable and
understandable later.

LS