Re: formating text in a textbox control?

Tech-Archive recommends: Fix windows errors by optimizing your registry

From: Curt_C [MVP] (software_AT_darkfalz.com)
Date: 12/10/04


Date: Fri, 10 Dec 2004 14:47:21 -0600

Do a null check around it.

if(drMain.Item("EstimatedDeliveryDate") != null)
{
txtETA.Text = drMain.Item("EstimatedDeliveryDate").ToShortDateString() ;
}
else
{
txtETA.Text = "";
}

-- 
Curt Christianson
Owner/Lead Developer, DF-Software
Site: http://www.Darkfalz.com
Blog: http://blog.Darkfalz.com
"djc" <noone@nowhere.com> wrote in message 
news:OjTvGbv3EHA.4008@TK2MSFTNGP15.phx.gbl...
> Is there a property or method of the textbox web server control that I can
> use to format the text in it a certian way. For example I am displaying a
> date value from a database in a text box. It displays like so: mm/dd/yyyy
> mm:hh:ss. I 'was' using the .ToShortDateString() function like so:
> txtETA.Text = drMain.Item("EstimatedDeliveryDate").ToShortDateString() 
> which
> worked great until I came across a database record with NULL for this 
> field.
> It seems the best thing to do would be to have something attatched to the
> textbox control itself that would control formating of it's own contents.
> That way I would not need to add a NULL check before using the
> .ToShortDateString() function.
>
> any input would be appreciated. Thanks!
>
> 


Relevant Pages

  • Re: formating text in a textbox control?
    ... Just like Curt said, you will have to do it in two steps. ... > Is there a property or method of the textbox web server control that I can ... > textbox control itself that would control formating of it's own contents. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: formating text in a textbox control?
    ... > This would be a compile time error, and you would already have to handle ... >> Is there a property or method of the textbox web server control that I ... >> textbox control itself that would control formating of it's own ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Getting a control linked to a database record - beginners question
    ... Perhaps if I could make each control id unique throughout the entire site, ... I have a control that I need to display text from an sql database. ... I would normally do this sort of thing via a querystring, ... which database record it needs without using querystrings? ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Getting a control linked to a database record - beginners question
    ... I guess the url combined with the control id would be a unique value. ... I have a control that I need to display text from an sql database. ... I would normally do this sort of thing via a querystring, ... which database record it needs without using querystrings? ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: formating text in a textbox control?
    ... > Curt Christianson ... >> Is there a property or method of the textbox web server control that I ... >> textbox control itself that would control formating of it's own ...
    (microsoft.public.dotnet.framework.aspnet)