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

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
 
E

Eliyahu Goldin

in c#:

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

Eliyahu
 
M

Matt Berther

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,575
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top