Date format in GridView control
-
Friends, I am using GridView control of ASP.NET 2.0. I want to format date column in the format of dd/mm/yyyy (it is showing me time and unwanted format). How can I do that? Thanks.
-
Friends, I am using GridView control of ASP.NET 2.0. I want to format date column in the format of dd/mm/yyyy (it is showing me time and unwanted format). How can I do that? Thanks.
Hi atul you have to write code in RowDataBound event of gridview. like this
if (e.Row.RowType == DataControlRowType.DataRow) { e.Row.Cells[3].Text = Convert.ToDateTime(ds.Tables[0].Rows[e.Row.RowIndex]["BDate"]).ToShortDateString(); } // here, ds is a dataset and "BDate" is a field name of the table
Pathan -
Friends, I am using GridView control of ASP.NET 2.0. I want to format date column in the format of dd/mm/yyyy (it is showing me time and unwanted format). How can I do that? Thanks.
-
Friends, I am using GridView control of ASP.NET 2.0. I want to format date column in the format of dd/mm/yyyy (it is showing me time and unwanted format). How can I do that? Thanks.
Thanks. I got solution by adding this. Without giving HtmlEncode="False", date format is not working. Wow !!