Set the date format

How to Set the current data into Asp text box in asp.net :


In asp.net programming it is very simple that u set the current date in specific format .if u want to set the current date in time and date both the  use:

Set Date:

TextBox1.Text=DateTime.Now.Date.ToString();

here TextBox1 is the Textbox id and dateTime.Now is function.
we want to set the current date with time in Text property of text.



how to to set the date format in to gridview in asp.net programming :

for this we use DateTime.Now.Date.ToString(); the current date set in textbox in String format.
If You want to want a specific  format the Give format in to ToString() function as like,

TextBox1.Text=DateTime.Now.Date.ToString("dd-MMM-yyy");

Format DateTime:

Where 
dd-MMM-yyy is a format of date :
  • dd- refer to date ,
  • MMM refer to Month, 
  • yyyy refer to Year.



Other Related Post :

Asp.net related post And Examples:

Comments

Popular posts from this blog