procedure Button1Click(Sender: System.Object; E:EventArgs); begin Calendar1.VisibleDate := System.Convert.ToDateTime(Edit1.Text); Label1.Text := ProdName + ' says you set ' + Calendar1.VisibleDate.ToString('D'); end; procedure Button2Click(Sender: System.Object; E:EventArgs); begin DisplayFields.Text := DispFields; end; function GetOrders(Date : DateTime) : DataSet; var Adapter : SqlDataAdapter; begin Adapter := SqlDataAdapter.Create( 'select ' + DisplayFields.Text + ' from Orders '+ 'where OrderDate = ''' + date.ToString('d')+'''', 'Server=(local);Database=Northwind;Trusted_Connection=yes'); Result := DataSet.Create; Adapter.Fill(Result); end; </script> <body style="font:18pt Verdana"> <form runat="server"> <h1><%=ProdName %> with a Calendar, DataGrid, & SqlClient in ASP.NET</h1> <table> <tr valign="top"><td> <p><b>Pick a date</b></p> <asp:Calendar id="Calendar1" runat="server" ForeColor="#0000FF" BackColor="#FFFFCC" OnSelectionChanged="DateSelected"> <TodayDayStyle Font-Bold="True"/> <NextPrevStyle ForeColor="#FFFFCC"/> <DayHeaderStyle BackColor="#FFCC66"/> <SelectedDayStyle ForeColor="Black" BackColor="#CCCCFF"/> <TitleStyle Font-Size="14pt" Font-Bold="True" ForeColor="#FFFFCC" BackColor="#990000"/> <OtherMonthDayStyle ForeColor="#CC9966"/> </asp:Calendar> <p><asp:TextBox id="Edit1" width=150 runat="server"/> <asp:Button text="Set date" id="Button1" OnClick="Button1Click" runat="server" /> </p> </td><td valign="top"> <p><b>Display fields:</b> <asp:TextBox id="DisplayFields" text="OrderID, CustomerID, ShipName, ShipCity, ShipCountry" width=500 runat="server"/> <asp:Button text="Reset fields" id="Button2" OnClick="Button2Click" runat="server" /></p> <asp:DataGrid id="DataGrid1" runat="server" BorderColor="#FFCC66" ForeColor="#0000FF"> <HeaderStyle ForeColor="#FFFFCC" BackColor="#990000"/> </asp:DataGrid> </td></tr></table> <p><asp:Label id="Label1" runat="server"/></p> </form> </body> |