DATASET生成XML调用的方法:
private void WriteXmlToFile(string filename,DataSet thisDataSet)
{
if (thisDataSet == null) { return; }
// Create a file name to write to.
filename += ".xml";
filename = Server.MapPath("../CsGolf/OrderXML/"+filename);
// Create the FileStream to write with.
System.IO.FileStream myFileStream = new System.IO.FileStream
(filename, System.IO.FileMode.Create);
// Create an XmlTextWriter with the fileStream.
System.Xml.XmlTextWriter myXmlWriter =
new System.Xml.XmlTextWriter(myFileStream, System.Text.Encoding.Unicode);
// Write to the file with the WriteXml method.
thisDataSet.WriteXml(myXmlWriter);
myXmlWriter.Close();
}数据库中日期为:2004-09-15 0:00:00
XML生成后为:2004-09-15T00:00:00.0000000+08:00
我重新从XML读取DATASET,再绑定到DATAGRID后,显示为:2004-09-15T00:00:00.0000000+08:00
DATAGRID中设置了格式化,但是无效,格式为:{0:yyyy-MM-dd}如何在DATAGRID中,显示为:2004-09-15
private void WriteXmlToFile(string filename,DataSet thisDataSet)
{
if (thisDataSet == null) { return; }
// Create a file name to write to.
filename += ".xml";
filename = Server.MapPath("../CsGolf/OrderXML/"+filename);
// Create the FileStream to write with.
System.IO.FileStream myFileStream = new System.IO.FileStream
(filename, System.IO.FileMode.Create);
// Create an XmlTextWriter with the fileStream.
System.Xml.XmlTextWriter myXmlWriter =
new System.Xml.XmlTextWriter(myFileStream, System.Text.Encoding.Unicode);
// Write to the file with the WriteXml method.
thisDataSet.WriteXml(myXmlWriter);
myXmlWriter.Close();
}数据库中日期为:2004-09-15 0:00:00
XML生成后为:2004-09-15T00:00:00.0000000+08:00
我重新从XML读取DATASET,再绑定到DATAGRID后,显示为:2004-09-15T00:00:00.0000000+08:00
DATAGRID中设置了格式化,但是无效,格式为:{0:yyyy-MM-dd}如何在DATAGRID中,显示为:2004-09-15
{
if(e.Item.ItemType==ListItemType.Item||e.Item.ItemType==ListItemType.AlternatingItem)
{
e.Item.Cells[i].Text = e.Item.Cells[i].Text.Substring(0,9);
}
}
ds.Tables[0].Rows[0][0]=myDTime.ToString("yyyy-MM-dd hh:ss:mm");
ds.WriteXml(myXmlWriter)
我用WriteXmlSchema方法生成都是些string类型,如何设置数据类型?
Private Sub DG_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles DG.ItemDataBound If (e.Item.ItemType = ListItemType.Item Or e.Item.ItemType =
ListItemType.AlternatingItem) Then Dim mydate As DateTime = Convert.ToDateTime(e.Item.Cells(5).Text())
e.Item.Cells(0).Text = mydate.ToShortDateString End IfEnd Sub
大哥能不能详细说明白点?
<asp:BoundColumn DataField="FlightDate" HeaderText="起飞日期" DataFormatString="{0:yyyy-MM-dd}">
<HeaderStyle HorizontalAlign="Center" ForeColor="White"></HeaderStyle>
<ItemStyle HorizontalAlign="Center"></ItemStyle>
</asp:BoundColumn>
select convert(varchar, 生日, 20) from Employees