Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0is not a valid value for Decimalis not a valid value for Decimal
Previous
 
Next
New Post
8/28/2007 2:15 PM
 

my BLL contains an EmployeeInfo.cs class with the following property declaration:

private decimal? _fee;

public decimal? Fee{
   get { return _fee;}
   set {_fee = value;}
}

On my .ascx page I have an ObjectDataSource bound to this class and a FormView control bound to the ObjectDataSource. When I try to insert a record via the FormView control and don't enter a value for Fee, I get an error saying: " is not a valid value for Decimal". The Fee field in the database table does accept null values.  I was hoping that making the _fee variable nullable would solve the problem but it didn't. I'm sure others must have encountered this because it's such a basic thing to want to do. Can anyone help me modify my code so that I don't get the error?

 
New Post
8/28/2007 10:49 PM
 

You could make your parameters optional that are passed to your functions that call your SQL server.  That might fix the problem.

Stuart


Hilbert Solutions, LLC
Owner, Hilbert Solutions, LLC
http://www.HilbertSolutions.com
A DNN Service Provider
From Module Development to DNN Upgrades, your one stop DNN Shop
 
New Post
8/29/2007 10:02 AM
 

Thanks, Stuart. Actually, the error was being raised when the FormView control tried to create a new object in the ObjectDataSource and was attempting to assign an empty string to a decimal? property. I fixed the problem by writing code in the FormView OnItemInserting event to catch the empty string and change it to null. Here's my code:

void FormView1_ItemInserting(object sender, FormViewInsertEventArgs e)//do the check for empty strings instead of decimals here and make the value null if necessary

 

// Iterate through the items in the Values collection

 

// if key=FeesFirst or key=FeesSecond and value="", change value to null

 

{

 

{

e.Values[entry.Key] =

}

}

foreach (DictionaryEntry entry in e.Values)if (entry.Value.Equals("") && (entry.Key.ToString() == "FeesFirst" || entry.Key.ToString() == "FeesSecond"))null;

protected

{

 

}

 
New Post
8/30/2007 11:29 AM
 

I realized that my code in my last post got messed up when I pasted it in. Here's the correct code:

protected void
FormView1_ItemInserting(object sender, FormViewInsertEventArgs e)

{
     foreach (DictionaryEntry entry in e.Values)   {
       if (entry.Value.Equals("") && (entry.Key.ToString() == "FeesFirst" || entry.Key.ToString() == "FeesSecond"))
       {
             e.Values[entry.Key] = null;
       }
    }
}

 
Previous
 
Next
HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0is not a valid value for Decimalis not a valid value for Decimal


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out