Ok,
Yet again, another issue that I am facing with the GridView control... :-)
Here are the steps for creating and populating my grid:
1. I construct my columns (mostly, GridViewTextBoxColumn, GridViewComboBoxColumn, GridViewDecimalColumn and GridViewDateTimeColumn) programmatically on form load. First of all, I construct these columns using xml data for the Fieldname properties etc.
Here is an example:
2. After I constructed these columns, I go ahead and initialize the grid by assigning it a datasource. The DataSet in turn is populated with xml data:
The xml data that I read into the DataSet looks like this:
3. When setting following properties on the GridViewDateTimeColumn as follows:
nothing happens... I've tried to set the properties both before and after I set the gridview's datasource with no success.
Also, I'm using the ExportToExcelML class for exporting and I always end up with data for the date field looking like this: 1/27/2011 12:00:00 AM in both the grid and exported excel spreadsheet which is wrong.
Is there anything I'm doing wrong somewhere?
I appreciate your help.
Thanks
Yet again, another issue that I am facing with the GridView control... :-)
Here are the steps for creating and populating my grid:
1. I construct my columns (mostly, GridViewTextBoxColumn, GridViewComboBoxColumn, GridViewDecimalColumn and GridViewDateTimeColumn) programmatically on form load. First of all, I construct these columns using xml data for the Fieldname properties etc.
Here is an example:
foreach
(XmlNode mapNode
in
mappingXmlDoc.SelectSingeNode(
"Mappings"
))
{
// Maps to GridViewDateTimeColumn
if
(elementPrefix ==
"dt"
)
{
GridViewDateTimeColumn col =
new
GridViewDateTimeColumn();
col.Name = mapNode.Name;
col.FieldName = mapNode.Name;
col.HeaderText = friendlyName;
radGridView1.Columns.Add(col);
}
}
2. After I constructed these columns, I go ahead and initialize the grid by assigning it a datasource. The DataSet in turn is populated with xml data:
DataSet dsData =
new
DataSet();
dsData.ReadXml(xmlFile);
radGridView.DataSource = dsData.Tables[0];
The xml data that I read into the DataSet looks like this:
<
assets
>
<
asset
>
<
tb_Desc
></
tb_Desc
>
<
dt_MoveDate
><
dt_MoveDate
>
</
asset
>
</
assets
>
3. When setting following properties on the GridViewDateTimeColumn as follows:
foreach
(GridViewDataColumn
in
radGridView1.Columns)
{
string[] strArr = col.FieldName.Split(
new
char
[] {
'_'
});
// This way I know its a GridViewDateTimeColumn
if
(strArr[0] ==
"dt"
)
{
((GridViewDateTimeColumn)col).ExcelExportType = DisplayFormatType.Custom;
((GridViewDateTimeColumn)col).ExcelExportFormatString =
"dd.mm.YYYY"
;
((GridViewDateTimeColumn)col).FormatString =
"{0:dd.mm.YYYY}"
;
}
}
nothing happens... I've tried to set the properties both before and after I set the gridview's datasource with no success.
Also, I'm using the ExportToExcelML class for exporting and I always end up with data for the date field looking like this: 1/27/2011 12:00:00 AM in both the grid and exported excel spreadsheet which is wrong.
Is there anything I'm doing wrong somewhere?
I appreciate your help.
Thanks