c# - Format exception was unhandled by user code -


@foreach (var result in model)       {                       ////var num=convert.toint32(x);         //int n=int.parse(x);         //int n=integer.parseint(x);                   if (convert.toint64(@result.difference) < 0)       {       <tr>         <td>@result.salesincentivebuckets         </td>         <td>@result.currentmonth         </td>         <td>@result.samemonthprevyear         </td>         <td style="color:red;">@result.difference         </td>          <td>@result.bonusamount         </td>       </tr>       }       else       {       <tr>          <td>@result.salesincentivebuckets          </td>          <td>@result.currentmonth          </td>          <td>@result.samemonthprevyear          </td>          <td>@result.difference          </td>           <td>@result.bonusamount          </td>        </tr>       }     } 

in model difference string, , want convert integeri tried in ways could, showing error:

input string not in correct format

it's commas in string causing exception, try

int num = int.parse(result.difference, numberstyles.allowthousands); 

you have add system.globalization namespace achieve this.


Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -