ASPForums.Net RSS Feedhttp://www.aspforums.net/Handlers/RSS.ashxLatest additions to the content that appears on ASPForums.Net(c) 2019 www.aspforums.com. All rights reserved.System.FormatException: Input string was not in a correct format while parsing value to integer and decimal in ASP.NetHi @nedash,<br />Please try the following<br /><br /><a href = 'link(Threads/462958/Input-string-was-not-in-a-correct-format/)'>Input string was not in a correct format.</a><br /><br />It might help you.<br /><br />Cheers Andrea.https://www.aspforums.net:443/Threads/152381/SystemFormatException-Input-string-was-not-in-a-correct-format-while-parsing-value-to-integer-and-decimal-in-ASPNet/https://www.aspforums.net:443/Threads/152381/SystemFormatException-Input-string-was-not-in-a-correct-format-while-parsing-value-to-integer-and-decimal-in-ASPNet/Mon, 27 Mar 2017 11:06:40 GMTSystem.FormatException: Input string was not in a correct format while parsing value to integer and decimal in ASP.Net<p>I change code like:</p> <pre class="brush: csharp">decimal rahn2 = decimal.Parse (Txtrahn2.Text);</pre> <p>but again error happen...</p> <p>&nbsp;</p>https://www.aspforums.net:443/Threads/152381/SystemFormatException-Input-string-was-not-in-a-correct-format-while-parsing-value-to-integer-and-decimal-in-ASPNet/https://www.aspforums.net:443/Threads/152381/SystemFormatException-Input-string-was-not-in-a-correct-format-while-parsing-value-to-integer-and-decimal-in-ASPNet/Tue, 28 Mar 2017 01:20:15 GMTSystem.FormatException: Input string was not in a correct format while parsing value to integer and decimal in ASP.Net<blockquote><cite>nedash says:</cite> <pre>Txtrahn2.Text</pre> </blockquote> <p>&nbsp;What the value you are passing in Txtrahn2.Text</p>https://www.aspforums.net:443/Threads/152381/SystemFormatException-Input-string-was-not-in-a-correct-format-while-parsing-value-to-integer-and-decimal-in-ASPNet/https://www.aspforums.net:443/Threads/152381/SystemFormatException-Input-string-was-not-in-a-correct-format-while-parsing-value-to-integer-and-decimal-in-ASPNet/Tue, 28 Mar 2017 04:02:00 GMTSystem.FormatException: Input string was not in a correct format while parsing value to integer and decimal in ASP.Net<blockquote><cite>dharmendr says:</cite> <pre>&nbsp;What the value you are passing in Txtrahn2.Text</pre> </blockquote> <p>&nbsp;nothing below are codes:</p> <pre class="brush: csharp">&lt;asp:UpdatePanel ID=&#34;UpdatePanel7&#34; runat=&#34;server&#34;&gt; &lt;ContentTemplate&gt; &lt;div id=&#34;AmFoD12&#34; runat=&#34;server&#34; &gt; &lt;asp:TextBox ID=&#34;Txtrahn2&#34; runat=&#34;server&#34; CssClass=&#34;vadi1&#34;&gt;&lt;/asp:TextBox&gt; &lt;asp:TextBox ID=&#34;Txtrahn1&#34; runat=&#34;server&#34; CssClass=&#34;vadi2&#34;&gt;&lt;/asp:TextBox&gt; &lt;/div&gt; &lt;/ContentTemplate&gt; &lt;/asp:UpdatePanel&gt;</pre> <p>&nbsp;</p> <p>Best regards</p> <p>neda</p> <p>&nbsp;</p>https://www.aspforums.net:443/Threads/152381/SystemFormatException-Input-string-was-not-in-a-correct-format-while-parsing-value-to-integer-and-decimal-in-ASPNet/https://www.aspforums.net:443/Threads/152381/SystemFormatException-Input-string-was-not-in-a-correct-format-while-parsing-value-to-integer-and-decimal-in-ASPNet/Tue, 28 Mar 2017 04:37:47 GMTSystem.FormatException: Input string was not in a correct format while parsing value to integer and decimal in ASP.Net<blockquote><cite>nedash says:</cite> <div class="line number1 index0 alt2"><code class="csharp keyword">if</code> <code class="csharp plain">(!IsPostBack)</code></div> <div class="line number2 index1 alt1"><code class="csharp plain">{ </code><code class="csharp keyword">int</code> <code class="csharp plain">rahn2 = </code><code class="csharp keyword">int</code><code class="csharp plain">.Parse(Txtrahn2.Text);</code></div> <div class="line number3 index2 alt2"><code class="csharp spaces">&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="csharp keyword">int</code> <code class="csharp plain">rahn1 = </code><code class="csharp keyword">int</code><code class="csharp plain">.Parse(Txtrahn1.Text);</code></div> <div class="line number4 index3 alt1"><code class="csharp plain">}</code></div> </blockquote> <p>Change above with the below code.</p> <pre class="brush: csharp">if (!IsPostBack) { int rahn2 = int.Parse(string.IsNullOrEmpty(Txtrahn2.Text) ? &#34;0&#34; : Txtrahn2.Text); int rahn1 = int.Parse(string.IsNullOrEmpty(Txtrahn1.Text) ? &#34;0&#34; : Txtrahn1.Text); }</pre> <p>OR</p> <pre class="brush: csharp">if (!IsPostBack) { decimal rahn2 = decimal.Parse(string.IsNullOrEmpty(Txtrahn2.Text) ? &#34;0&#34; : Txtrahn2.Text); decimal rahn1 = decimal.Parse(string.IsNullOrEmpty(Txtrahn1.Text) ? &#34;0&#34; : Txtrahn1.Text); }</pre> <p>&nbsp;</p>https://www.aspforums.net:443/Threads/152381/SystemFormatException-Input-string-was-not-in-a-correct-format-while-parsing-value-to-integer-and-decimal-in-ASPNet/https://www.aspforums.net:443/Threads/152381/SystemFormatException-Input-string-was-not-in-a-correct-format-while-parsing-value-to-integer-and-decimal-in-ASPNet/Tue, 28 Mar 2017 04:52:10 GMT