home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 40 / IOPROG_40.ISO / SOFT / NETFrameworkSDK.exe / comsdk.cab / samples.exe / QuickStart / aspplus / samples / trace / trace1.aspx next >
Encoding:
ASP.NET Web Form  |  2000-05-12  |  2.4 KB  |  72 lines

  1. <%@ Page Trace="true" %>
  2.  
  3. <%@ Import NameSpace="System.Data" %>
  4. <%@ Import NameSpace="System.Data.SQL" %>
  5.  
  6.  
  7. <html>
  8.  
  9. <script language="C#" runat="server">
  10.  
  11.   public void Page_Load(Object sender, EventArgs E)
  12.   {
  13.     if (!IsPostBack)
  14.     {
  15.       SQLConnection myConnection = new SQLConnection("server=localhost;uid=sa;pwd=;database=grocertogo");
  16.       SQLDataSetCommand myCommand = new SQLDataSetCommand("select distinct CategoryName from Categories", myConnection);
  17.  
  18.       DataSet ds = new DataSet();
  19.       myCommand.FillDataSet(ds, "Categories");
  20.  
  21.       Categories.DataSource = ds.Tables["Categories"].DefaultView;
  22.       Categories.DataBind();
  23.     }
  24.   }
  25.  
  26.   public void Submit_Click(Object sender, EventArgs E)
  27.   {
  28.     SQLConnection myConnection = new SQLConnection("server=localhost;uid=sa;pwd=;database=grocertogo");
  29.     SQLDataSetCommand myCommand = new SQLDataSetCommand("select ProductName, ImagePath, UnitPrice, c.CategoryId  from Products p, Categories c where c.CategoryName='" + Categories.SelectedItem.Value + "' and p.CategoryId = c.CategoryId", myConnection);
  30.  
  31.     DataSet ds = new DataSet();
  32.     myCommand.FillDataSet(ds, "Products");
  33.  
  34.     Products.DataSource = ds.Tables["Products"].DefaultView;
  35.     Products.DataBind();
  36.   }
  37.  
  38. </script>
  39.  
  40. <body style="font: 10pt verdana" bgcolor="ffffcc">
  41.  
  42.   <form runat="server">
  43.  
  44.   <h3>Enabling Trace Ouput for a Page</h3>
  45.  
  46.   Select a Category: 
  47.  
  48.   <ASP:DropDownList id="Categories" DataValueField="CategoryName" runat="server"/>
  49.  
  50.   <input type="Submit" OnServerClick="Submit_Click" Value="Get Products" runat="server"/><p>
  51.  
  52.   <ASP:DataList id="Products" ShowHeader=false ShowFooter=false RepeatDirection="horizontal" BorderWidth=0 runat="server">
  53.  
  54.     <template name="itemtemplate">
  55.       <table>
  56.         <tr>
  57.           <td width="150" style="text-align:center; font-size:8pt; vertical-align:top; height:200">
  58.             <ASP:ImageButton borderwidth=6 bordercolor="#ffffcc" command="Select" ImageUrl='<%# DataBinder.Eval(Container.DataItem, "ImagePath") %>' runat="server"/>
  59.             <p>
  60.             <%# DataBinder.Eval(Container.DataItem, "ProductName") %> <br>
  61.             <%# DataBinder.Eval(Container.DataItem, "UnitPrice", "{0:C}").ToString() %>
  62.           </td>
  63.         </tr>
  64.       </table>
  65.     </template>
  66.                                              
  67.   </ASP:DataList>
  68.  
  69.   </form> 
  70.  
  71. </body>
  72. </html>