NestedPanels.aspx 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. <%@ Page Language="C#" %>
  2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  3. <html xmlns="http://www.w3.org/1999/xhtml" >
  4. <head runat="server">
  5. <title>Browse Departments</title>
  6. <script runat="server">
  7. protected void DepartmentsGridView_RowDataBound(object sender, GridViewRowEventArgs e)
  8. {
  9. if (e.Row.RowType == DataControlRowType.DataRow)
  10. {
  11. SqlDataSource s = (SqlDataSource)e.Row.FindControl("EmployeesDataSource");
  12. System.Data.DataRowView r = (System.Data.DataRowView)e.Row.DataItem;
  13. s.SelectParameters["DepartmentID"].DefaultValue = r["DepartmentID"].ToString();
  14. }
  15. }
  16. </script>
  17. </head>
  18. <body>
  19. <form id="form1" runat="server">
  20. <div>
  21. <asp:ScriptManager runat="server" ID="ScriptManager1" EnablePartialRendering="true" />
  22. <asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Conditional">
  23. <ContentTemplate>
  24. <asp:GridView ID="DepartmentsGridView" runat="server" AllowPaging="True" AllowSorting="True"
  25. AutoGenerateColumns="False" CellPadding="4" DataSourceID="DepartmentDataSource"
  26. ForeColor="#333333" GridLines="None" PageSize="3" OnRowDataBound="DepartmentsGridView_RowDataBound">
  27. <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
  28. <Columns>
  29. <asp:BoundField DataField="GroupName" HeaderText="Division" SortExpression="GroupName" >
  30. <ItemStyle Width="200px" />
  31. </asp:BoundField>
  32. <asp:BoundField DataField="Name" HeaderText="Department Name" SortExpression="Name" >
  33. <ItemStyle Width="160px" />
  34. </asp:BoundField>
  35. <asp:TemplateField HeaderText="Employees">
  36. <ItemTemplate>
  37. <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
  38. <ContentTemplate>
  39. <asp:GridView ID="EmployeesGridView" runat="server" AllowPaging="True" AllowSorting="True"
  40. AutoGenerateColumns="False" BackColor="White" BorderColor="#999999" BorderStyle="None"
  41. BorderWidth="1px" CellPadding="3" DataSourceID="EmployeesDataSource" GridLines="Vertical"
  42. PageSize="4">
  43. <FooterStyle BackColor="#CCCCCC" ForeColor="Black" />
  44. <Columns>
  45. <asp:BoundField DataField="FirstName" HeaderText="First Name" SortExpression="FirstName" >
  46. <ItemStyle Width="80px" />
  47. </asp:BoundField>
  48. <asp:BoundField DataField="LastName" HeaderText="Last Name" SortExpression="LastName" >
  49. <ItemStyle Width="160px" />
  50. </asp:BoundField>
  51. </Columns>
  52. <RowStyle BackColor="#EEEEEE" ForeColor="Black" />
  53. <SelectedRowStyle BackColor="#008A8C" Font-Bold="True" ForeColor="White" />
  54. <PagerStyle BackColor="#999999" ForeColor="Black" HorizontalAlign="Center" />
  55. <HeaderStyle BackColor="#000084" Font-Bold="True" ForeColor="White" />
  56. <AlternatingRowStyle BackColor="Gainsboro" />
  57. </asp:GridView>
  58. <asp:Label runat="server" ID="InnerTimeLabel"><%=DateTime.Now %></asp:Label>
  59. <asp:SqlDataSource ID="EmployeesDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:AdventureWorksConnectionString %>"
  60. SelectCommand="SELECT HumanResources.EmployeeDepartmentHistory.DepartmentID,
  61. HumanResources.vEmployee.EmployeeID,
  62. HumanResources.vEmployee.FirstName,
  63. HumanResources.vEmployee.LastName
  64. FROM HumanResources.EmployeeDepartmentHistory
  65. INNER JOIN HumanResources.vEmployee
  66. ON HumanResources.EmployeeDepartmentHistory.EmployeeID = HumanResources.vEmployee.EmployeeID
  67. WHERE HumanResources.EmployeeDepartmentHistory.DepartmentID = @DepartmentID
  68. ORDER BY HumanResources.vEmployee.LastName ASC, HumanResources.vEmployee.FirstName ASC">
  69. <SelectParameters>
  70. <asp:Parameter Name="DepartmentID" DefaultValue="0" Type="int32" />
  71. </SelectParameters>
  72. </asp:SqlDataSource>
  73. </ContentTemplate>
  74. </asp:UpdatePanel>
  75. </ItemTemplate>
  76. <ItemStyle Height="170px" Width="260px" />
  77. </asp:TemplateField>
  78. </Columns>
  79. <RowStyle BackColor="#F7F6F3" ForeColor="#333333" VerticalAlign="Top" />
  80. <EditRowStyle BackColor="#999999" />
  81. <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
  82. <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
  83. <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" HorizontalAlign="Left" />
  84. <AlternatingRowStyle BackColor="White" ForeColor="#284775" VerticalAlign="Top" />
  85. </asp:GridView>
  86. <asp:Label runat="server" ID="OuterTimeLabel"><%=DateTime.Now %></asp:Label>
  87. </ContentTemplate>
  88. </asp:UpdatePanel>
  89. &nbsp;
  90. <asp:SqlDataSource ID="DepartmentDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:AdventureWorksConnectionString %>"
  91. SelectCommand="SELECT DepartmentID, Name, GroupName FROM HumanResources.Department ORDER BY Name">
  92. </asp:SqlDataSource>
  93. </div>
  94. </form>
  95. </body>
  96. </html>