<%@ Register TagPrefix="Title" TagName="TitleShow" Src="/aspnetdata/Title.ascx" %>
<%@Import Namespace="System.Threading"%>
<%@Import Namespace="System.Globalization"%>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<%@ Import Namespace="System.Web" %>
<html>
  <script language="C#" runat=server>
	SqlConnection Source;
	string d="SELECT * from Orders";
	void Page_Load(object sender,EventArgs e){
		Source = (SqlConnection)Session["NowSTKSQL"];
		if(IsPostBack==false){
			CurrentC.Text=Thread.CurrentThread.CurrentCulture.Name;
			bindNew(true);
		}
	}
	void bindNew(Boolean tag){
		if(tag==true){
			DataSet DS = new DataSet();
			SqlDataAdapter NComm = new SqlDataAdapter(d, Source);
			NComm.Fill(DS, "Orders");
			Orders.DataSource=DS.Tables["Orders"].DefaultView;
			Orders.DataBind();
			Session["NowAD1"]=DS;//声明为Session
		}
		else{
			DataSet DS=(DataSet)Session["NowAD1"];
			Orders.DataSource=DS.Tables["Orders"].DefaultView;
			Orders.DataBind();
		}
	}
	void OK_Click(object sender,EventArgs e){
		CultureInfo cult;//声明及建立新语言
		cult = new CultureInfo(Thread.CurrentThread.CurrentCulture.Name);
		DateTimeFormatInfo j=cult.DateTimeFormat;//取得日期格式对象
		j.LongDatePattern=DatePattern.Text;
		NumberFormatInfo k=cult.NumberFormat;//取得数字格式对象
		k.CurrencySymbol=CurrencySym.Text;
		Thread.CurrentThread.CurrentCulture = cult;
		bindNew(false);
	}
  </script>
<body background="/aspnetdata/images/winback.gif">
<Title:TitleShow id="BookT" Runat="server" />
    <form runat=server>
Current Culture name : <asp:label id="CurrentC" runat="server" /><br>
InputLongDatePattern : <asp:Textbox id="DatePattern" runat="server" width="110"/>(y、M、d)<br>
Input Currency Synbol : <asp:Textbox id="CurrencySym" runat="server" width="60"/>
<asp:Button Text="OK" runat="server" onclick="OK_Click" />
<br>      <ASP:DataGrid id="Orders" runat="server"
        BorderColor="black"
        BorderWidth="1"
        GridLines="Both"
        CellPadding="3"
        CellSpacing="0"
        Font-Name="Verdana"
        Font-Size="10pt"
        HeaderStyle-BackColor="LightYellow"
	HeaderStyle-HorizontalAlign="Center"
	AutoGenerateColumns="FALSE"
	SelectedItemStyle-BackColor="#FFFFC0"
	ItemStyle-HorizontalAlign="right"
	EditItemStyle-HorizontalAlign="right"
	DataKeyField="OrderID"
>
      <Columns>
	<asp:TemplateColumn HeaderText="OrderID" >
		<ItemTemplate>
			<asp:Label runat="server" Text=<%# DataBinder.Eval(Container.DataItem, "OrderID") %> id="OrderID"/>
		</ItemTemplate>
	</asp:TemplateColumn>
	<asp:TemplateColumn HeaderText="OrderDate" >
		<ItemTemplate>
			<asp:Label runat="server" Text=<%# DataBinder.Eval(Container.DataItem, "OrderDate","{0:D}") %> id="OrderDate"/>
		</ItemTemplate>
	</asp:TemplateColumn>
	<asp:TemplateColumn HeaderText="Customer" >
		<ItemTemplate>
			<asp:Label runat="server" Text=<%# DataBinder.Eval(Container.DataItem, "CusID") %> id="CusID"/>
		</ItemTemplate>
	</asp:TemplateColumn>
	<asp:TemplateColumn HeaderText="TotalPrice" >
		<ItemTemplate>
			<asp:Label runat="server" Text=<%# DataBinder.Eval(Container.DataItem, "TotalPrice","{0:C}") %> id="Total"/>
		</ItemTemplate>
	</asp:TemplateColumn>
	</Columns>
</asp:DataGrid>
</form>