bsp; for(int i=0;i<e.Item.Cells.Count;i++)
{
e.Item.Cells[i].Wrap = false;
string columnName=drv.Row.Table.Columns[i].ColumnName;
if( columnName.StartsWith("我") )
{
e.Item.Cells[i].Text = ((DateTime)drv[columnName]).ToString("yyyy-MM-dd");
//也可以这样
//e.Item.Cells[i].Text = DataBinder.Eval(e.Item.DataItem,columnName,"{0:yyyy-MM-dd}");
}
if( columnName.StartsWith("俺") )
{
e.Item.Cells[i].Text = ((DateTime)drv[columnName]).ToString("dd/MM/yy");
//也可以这样
//e.Item.Cells[i].Text = DataBinder.Eval(e.Item.DataItem,columnName,"{0:yy-MM-dd}");
}
}
}
}
</script>
</head>
<body>
<form runat="server">
<ASP:DataGrid id="dg" runat="server"
HeaderStyle-BackColor="#aaaadd"
AutoGenerateColumns="true"
OnItemDataBound="ItemDataBound"
Width="100%"
>
</asp:DataGrid>
</form>
</body>
</html>
http://www.aspxboy.com/Files/71/66/285.Aspx
http://huobazi.cnblogs.com/archive/2004/11/16/64354.html