sql - how to remove NullExceptionError from Session Variable -


I have a varible sem which takes input from the textbox, but if the text box is kept blank, then I I want to return "please" one semester "

  int semicolore; if int.TryParse (Textbox2.Text, parsevalue out)) {sem = parsevalue; session [" bean " ] = Cm;} Other {Literal2.Text = "Please enter one semester";}  

But if the textbox is empty, then session ["bean"] Return NullExceptionError in .aspx in which the file I have used it.

I used the tryparse to search for the proper conversion but it did not clearly understand how to print the error message above. Please thank you in advance

Your correct code is here:

  int sem; Int parsevalue; If (int.TryParse (Textbox2.Text, parsevalue out)) {sem = parsevalue; } Other {Literal2.Text = "Please enter one semester"; } // Always set the session variables when it is used in another session ["beans"] = sem;  

Comments

Popular posts from this blog

c# - sqlDecimal to decimal clr stored procedure Unable to cast object of type 'System.Data.SqlTypes.SqlDecimal' to type 'System.IConvertible' -

Calling GetGUIThreadInfo from Outlook VBA -

Obfuscating Python code? -