|
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Hierarchy.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<br />
<div>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
SelectCommand="SELECT [CategoryID], [CategoryName] FROM [Categories]"></asp:SqlDataSource>
<asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
SelectCommand="SELECT [CategoryID], [ProductName] FROM [Products] WHERE CategoryID=@Category">
<SelectParameters>
<asp:ControlParameter ControlID="ListBox1" Name="Category" PropertyName="SelectedValue" />
</SelectParameters>
</asp:SqlDataSource><asp:SqlDataSource ID="SqlDataSource3" runat="server" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
SelectCommand="SELECT [CategoryID], [CategoryName] FROM [Categories]"></asp:SqlDataSource>
<asp:SqlDataSource ID="SqlDataSource4" runat="server" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
SelectCommand="SELECT [CategoryID], [ProductName] FROM [Products] WHERE CategoryID=@Category">
<SelectParameters>
<asp:ControlParameter ControlID="ListBox3" Name="Category" PropertyName="SelectedValue" />
</SelectParameters>
</asp:SqlDataSource>
<br />
<table>
<tr>
<td style="width: 1px">
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
Sample with AJAX<asp:ListBox ID="ListBox1" runat="server" AutoPostBack="True" DataSourceID="SqlDataSource1"
DataTextField="CategoryName" DataValueField="CategoryID" Height="204px" Width="226px">
</asp:ListBox><br />
<asp:ListBox ID="ListBox2" runat="server" DataSourceID="SqlDataSource2" DataTextField="ProductName"
DataValueField="CategoryID" Height="201px" Width="225px"></asp:ListBox>
</ContentTemplate>
</asp:UpdatePanel>
</td>
<td style="width: 176px">
<br />
<br />
Sample without AJAX<asp:ListBox ID="ListBox3" runat="server" AutoPostBack="True"
DataSourceID="SqlDataSource3" DataTextField="CategoryName" DataValueField="CategoryID"
Height="204px" Width="226px"></asp:ListBox>
<asp:ListBox ID="ListBox4" runat="server" DataSourceID="SqlDataSource4" DataTextField="ProductName"
DataValueField="CategoryID" Height="201px"
Width="225px"></asp:ListBox></td>
</tr>
</table>
</div>
</form>
</body>
</html>
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
I am Web Developer at Messages, a printing company in Toulouse, France. I am particularly interested about Blazor, but my primary development platform at work is ASP.NET MVC with C#. I have 15 years experience in developing software, always using Microsoft Technologies.