display date in datagrid instead of date and time
-
i want to display date in a datagrid column. To fill that datagrid i am filling data to a dataset and i am assigning that data set to datagrid.what my problem is that i am not able to display only date in that column.the time also is displaying with date.if i want to display time only then date also is coming along with time. please help me to solve this problem
saravanan
-
i want to display date in a datagrid column. To fill that datagrid i am filling data to a dataset and i am assigning that data set to datagrid.what my problem is that i am not able to display only date in that column.the time also is displaying with date.if i want to display time only then date also is coming along with time. please help me to solve this problem
saravanan
use the ToShortDateString() method...
DateTime dt = new DateTime();
string str = dt.ToShortDateString();"Now I guess I'll sit back and watch people misinterpret what I just said......" Christian Graus At The Soapbox
-
i want to display date in a datagrid column. To fill that datagrid i am filling data to a dataset and i am assigning that data set to datagrid.what my problem is that i am not able to display only date in that column.the time also is displaying with date.if i want to display time only then date also is coming along with time. please help me to solve this problem
saravanan
if you are pulling the data from database, try to do the date formating in sql server like CONVERT(VARCHAR,column name,101)
-
i want to display date in a datagrid column. To fill that datagrid i am filling data to a dataset and i am assigning that data set to datagrid.what my problem is that i am not able to display only date in that column.the time also is displaying with date.if i want to display time only then date also is coming along with time. please help me to solve this problem
saravanan
Saravanainit_2004@yahoo.com wrote:
display date in datagrid instead of date and time
1. Use formatter for DateTime fields. 2. mydate.ToString("dd/mm/yyyy"), mytime.ToString("hh:mm tt") mydate and mytime are variables of DateTime. Use the TemplateField for DateTime fields in GridView and override RowDateBound method of GridView and use the FindControl to find the label in GridViewRow.Assign the formated date to that label. That's it. :) Knock out 't' from can't, You can if you think you can :cool:
-
i want to display date in a datagrid column. To fill that datagrid i am filling data to a dataset and i am assigning that data set to datagrid.what my problem is that i am not able to display only date in that column.the time also is displaying with date.if i want to display time only then date also is coming along with time. please help me to solve this problem
saravanan
-
Try: <%# Convert.ToDateTime(DataBinder.Eval(Container.DataItem, "YourDateTimeFieldHere")).ToString("MM/dd/yyyy") #> Hope that helps. Ben -- modified at 21:10 Thursday 22nd March, 2007
Goto Prpoerty Builder and Use {d:0} in DataFormatting String.. :laugh: