By default zero showing in the text box of .aspx page?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi experts,

I defined two integer values in the class. Like this

public class IntegerClass
public ID1 as Int32
public ID2 as Int32
End Class

then iam instantiating this class and assigning these values to the text box
id. After if i run the application by deafult zero is showing in the two text
boxes.

I don't want display the zero by deafult it should be blank. How to avoid
this zeros.

Can any one help me on this.

Thanks in advance
 
in c#:

if (myIntegerClass.ID1 == 0)
txtBox.Text="";
else
txtBox.Text=myIntegerClass.ID1 ;

Eliyahu
 
Hello Pesani,

Int32 is a value type and therefore can not be assigned to null. It is always
initialized to 0. You should perform a check for zero, handling the situation
as appropriate.
 
Back
Top