Store Null Integer Values Without Conversion Error

   This one of the problem for using Asp.net Developers. Textbox can Store without any values to Press Button Event . To Display the Conversion Error.For Like This......

In this  state we can use Code as         
                                                          
int val2 = Convert.ToInt32(t2.Text);


To Use Another method to Empty Textbox  You can pressed to store Null value  to the Database  Without Any Conversion Error.

               string str = string.IsNullOrEmpty(t1.Text) ? "0" : t1.Text;
                                                        int val = Convert.ToInt32(str);

In this Method can Use Store or any Functionality.

Comments

Popular posts from this blog

Insecure cookie setting: missing Secure flag

Maximum Stored Procedure Function Trigger or View Nesting Level Exceeded (limit 32) in SQL Server

Display Line Chart Using Chart.js MVC C#