We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

DateTime string to ShortDate in DataBoundGrid

Thread ID:





17368 Aug 6,2004 03:33 PM UTC Aug 7,2004 08:20 AM UTC WinForms 2
Tags: GridControl
kevin musters
Asked On August 6, 2004 03:33 PM UTC

I have a datatable gets it''s datetimes as strings. I set my datasource of my databoundgrid to a datatable. When I load the grid, the date appears as "09/12/1998 12:00:00 AM" I want to format that column as the localized ShortDate of the computer (in this case is "09/12/1998") How can I achieve this without making the date column a drop down datepicker? Thanks, I''m really stuck.

Administrator [Syncfusion]
Replied On August 6, 2004 03:37 PM UTC

You should set the GridBoundColumnStyleInfo.CellValueType to typeof(DateTime) and then set the GridBoundColumnStyleInfo.Format to display what you want to see. If you do not want to see the buttons, then set GridBoundColumnStyleInfo.ShowButtons = hide.

Administrator [Syncfusion]
Replied On August 7, 2004 08:20 AM UTC

Here is a FormLoad that populates a GridDataBoundGrid with DateTime strings, and then formats one of the columns with the locale short date format.
private void Form1_Load(object sender, System.EventArgs e)
	DataTable dt = new DataTable("MyTable");
	int nCols = 4;
	int nRows = 10;
	for(int i = 0; i < nCols; i++)
	dt.Columns.Add(new DataColumn(string.Format("Col{0}", i)));
	for(int i = 0; i < nRows; ++i)
		DataRow dr = dt.NewRow();
		for(int j = 0; j < nCols; j++)
			dr[j] = string.Format("{0}", DateTime.Now);
	this.gridDataBoundGrid1.DataSource = dt;
	GridStyleInfo style = this.gridDataBoundGrid1.Binder.InternalColumns[2].StyleInfo;
	style.CellValueType = typeof(DateTime);
	style.Format = "d"; //local short date format


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon