WEBSWAPP Silverlight ASP.NET 3.5 ASP.NET 2.0 ASP.NET 1.0
Cascading Lists
AJAX ToolKit
Hierarchies
C#-ListView C#-GridView UpdatePanel
    
<%@ Register Src="wucCity.ascx" TagPrefix="uc" TagName="City" %> <%@ Register Src="wucAddressType.ascx" TagPrefix="uc" TagName="AddressType" %> <%@ Register Src="Explanation.ascx" TagPrefix="uc" TagName="Explanation" %> <%@ Page Language="C#" AutoEventWireup="true" %> <asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server"> </asp:Content> <asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server"> <asp:LinqDataSource ID="LinqDataSource1" runat="server" ContextTypeName="WEBSWAPP.Website.Data.SamplesDataContext" EnableDelete="True" EnableInsert="True" EnableUpdate="True" TableName="Addresses" > </asp:LinqDataSource> <h2> Cascading Dropdownlists within a ListView using LINQ</h2> <div> <asp:ListView ID="lvAddress" runat="server" DataKeyNames="Id,RecordVersion" DataSourceID="LinqDataSource1" InsertItemPosition="LastItem"> <ItemTemplate> <div class="halfWindowPanel left"> <span class="titleLabel">Suite#:</span> <asp:Label ID="lblSuiteNumber" runat="server" Text='<%# Eval("SuiteNumber") %>' /> <br /> <span class="titleLabel">Address Line 1:</span> <asp:Label ID="txtAddressLine1" runat="server" Text='<%# Eval("AddressLine1") %>' /> <br /> <span class="titleLabel">Address Line 2:</span> <asp:Label ID="AddressLine2Label" runat="server" Text='<%# Eval("AddressLine2") %>' /> <br /> <span class="titleLabel">Location:</span> <asp:Label ID="txtCity" runat="server" Text='<%# (((WEBSWAPP.Website.Data.Location)Eval("Location")).Name) + ", " + ((WEBSWAPP.Website.Data.Location)Eval("Location")).Location1.Name + ", " + ((WEBSWAPP.Website.Data.Location)((WEBSWAPP.Website.Data.Location)Eval("Location")).Location1).Location1.Name%>' /> <br /> <span class="titleLabel">Postal Code:</span> <asp:Label ID="txtPostalCode" runat="server" Text='<%# Eval("PostalCode") %>' /> <br /> <span class="titleLabel">Address Type:</span> <asp:Label ID="txtAddressType" runat="server" Text='<%# ((WEBSWAPP.Website.Data.AddressType)Eval("AddressType")).Name %>' /> <div class="commandBar"> <asp:Button ID="DeleteButton" runat="server" CommandName="Delete" Text="Delete" OnClientClick="return confirm('Are you sure you want to delete this record');" /> <asp:Button ID="EditButton" runat="server" CommandName="Edit" Text="Edit" /> </div> </div> </ItemTemplate> <EditItemTemplate> <div class="halfWindowPanel left"> <h3> Edit contact addresses</h3> <span class="titleLabel">Suite#:</span> <asp:TextBox ID="lblSuiteNumber" runat="server" MaxLength="10" Text='<%# Bind("SuiteNumber") %>' /> <br /> <span class="titleLabel">Address Line 1:</span> <asp:TextBox ID="txtAddressLine1" runat="server" MaxLength="60" Text='<%# Bind("AddressLine1") %>' /> <asp:RequiredFieldValidator ID="rfvAddressLine1" runat="server" ErrorMessage="You must enter an address line to save the record" Text="*" ValidationGroup="EditAddress" ControlToValidate="txtAddressLine1"></asp:RequiredFieldValidator> <br /> <span class="titleLabel">Address Line 2:</span> <asp:TextBox ID="AddressLine2Label" runat="server" MaxLength="60" Text='<%# Bind("AddressLine2") %>' /> <br /> <span class="titleLabel">Location:</span><br /> <uc:City runat="server" ID="ucCity" CityId='<%#Bind("CityId") %>' /> <br /> <span class="titleLabel">Postal Code:</span> <asp:TextBox ID="txtPostalCode" runat="server" MaxLength="15" Text='<%# Bind("PostalCode") %>' /> <br /> <span class="titleLabel">Address Type:</span> <uc:AddressType runat="server" ID="ucAddressType" AddressTypeId='<%#Bind("AddressTypeId") %>' /> <div class="commandBar"> <asp:Button ID="UpdateButton" runat="server" ValidationGroup="EditAddress" CommandName="Update" Text="Update" /> <asp:Button ID="CancelButton" runat="server" CausesValidation="false" CommandName="Cancel" Text="Cancel" /> </div> </div> </EditItemTemplate> <EmptyDataTemplate> <div class="halfWindowPanel left"> <p> No data was returned.</p> </div> </EmptyDataTemplate> <InsertItemTemplate> <div class="halfWindowPanel right white"> <span class="caption">Insert new contact address</span> <br /> <span class="titleLabel">Suite#:</span> <asp:TextBox ID="lblSuiteNumber" runat="server" MaxLength="10" Text='<%# Bind("SuiteNumber") %>' /> <br /> <span class="titleLabel">Address Line 1:</span> <asp:TextBox ID="txtAddressLine1" runat="server" MaxLength="60" Text='<%# Bind("AddressLine1") %>' /> <asp:RequiredFieldValidator ID="rfvAddressLine1" runat="server" ErrorMessage="You must enter an address line to save the record" Text="*" ValidationGroup="InsertAddress" ControlToValidate="txtAddressLine1"></asp:RequiredFieldValidator> <br /> <span class="titleLabel">Address Line 2:</span> <asp:TextBox ID="AddressLine2Label" runat="server" MaxLength="60" Text='<%# Bind("AddressLine2") %>' /> <br /> <span class="titleLabel">Location:</span><br /> <uc:City runat="server" ID="ucCity" CityId='<%#Bind("CityId") %>' /> <br /> <span class="titleLabel">Postal Code:</span> <asp:TextBox ID="txtPostalCode" runat="server" MaxLength="15" Text='<%# Bind("PostalCode") %>' /> <br /> <span class="titleLabel">Address Type:</span> <uc:AddressType runat="server" ID="ucAddressType" AddressTypeId='<%#Bind("AddressTypeId") %>' /> <br /> <div class="commandBar"> <asp:Button ID="InsertButton" runat="server" ValidationGroup="InsertAddress" CommandName="Insert" Text="Insert" /> <asp:Button ID="CancelButton" runat="server" CausesValidation="false" CommandName="Cancel" Text="Clear" /> <br /> </div> </div> </InsertItemTemplate> <LayoutTemplate> <div class="pagerStyle"> <asp:DataPager ID="DataPager1" runat="server" PageSize="1"> <Fields> <asp:NextPreviousPagerField ButtonType="Button" ShowFirstPageButton="True" ShowLastPageButton="True" /> </Fields> </asp:DataPager> </div> <div id="itemPlaceholder" runat="server"> </div> </LayoutTemplate> </asp:ListView> <asp:ValidationSummary runat="server" ID="valSumm" ValidationGroup="EditAddress" ShowSummary="false" ShowMessageBox="true" /> <asp:ValidationSummary runat="server" ID="ValidationSummary1" ValidationGroup="InsertAddress" ShowSummary="false" ShowMessageBox="true" /> <uc:Explanation runat="server"></uc:Explanation> </div> </asp:Content>