Set DefaultIntValue in C#.net
public static int DefaultIntValue(TextBox txt)
{
try
{
if (String.IsNullOrEmpty(txt.Text))
{
return 0;
}
else
{
return Convert.ToInt32(txt.Text);
}
}
catch (Exception ex)
{
Program.WriteLog(ex.Message, ex.StackTrace);
return 0;
}
}
{
try
{
if (String.IsNullOrEmpty(txt.Text))
{
return 0;
}
else
{
return Convert.ToInt32(txt.Text);
}
}
catch (Exception ex)
{
Program.WriteLog(ex.Message, ex.StackTrace);
return 0;
}
}