Hi all,
I have two tables in an SQL database. One contains Customer details and the other contains Contact names. There is a one to many relationship between Customers and Contacts. I have a Radgrid for the Customers table and I'm using a pop-up EditForm for insert/update. On the EditForm there is a RadCombo to select a contact. I only want to populate this combo with the Contact Names for the selected Customer.
Below is my code. Currently it' not populating the Combo Box at all. What am I doing wrong?
Many thanks in advance,
Neil
I have two tables in an SQL database. One contains Customer details and the other contains Contact names. There is a one to many relationship between Customers and Contacts. I have a Radgrid for the Customers table and I'm using a pop-up EditForm for insert/update. On the EditForm there is a RadCombo to select a contact. I only want to populate this combo with the Contact Names for the selected Customer.
Below is my code. Currently it' not populating the Combo Box at all. What am I doing wrong?
Many thanks in advance,
Neil
<%@ Page Title="" Language="VB" MasterPageFile="~/Pages/SiteMaster.master" AutoEventWireup="false" CodeFile="TestCustomers.aspx.vb" Inherits="Pages_Bookings_Customers" %> <%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %> <asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server"> </asp:Content> <asp:Content ID="Content2" ContentPlaceHolderID="phTopContent" Runat="Server"> </asp:Content> <asp:Content ID="Content3" ContentPlaceHolderID="phMainContent" Runat="Server"> <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" DefaultLoadingPanelID="RadAjaxLoadingPanel1"> <AjaxSettings> <telerik:AjaxSetting AjaxControlID="RadGrid1"> <UpdatedControls> <telerik:AjaxUpdatedControl ControlID="RadGrid1" LoadingPanelID="RadAjaxLoadingPanel1" /> </UpdatedControls> </telerik:AjaxSetting> </AjaxSettings> </telerik:RadAjaxManager> <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" MinDisplayTime="100" Skin="Sunset"> </telerik:RadAjaxLoadingPanel> <div style="float: none; clear: both"> <telerik:RadGrid ID="RadGrid1" runat="server" DataSourceID="dsCustomers" AllowAutomaticInserts="True" AllowAutomaticUpdates="True" AllowFilteringByColumn="True" AllowPaging="True" AllowSorting="True" GridLines="None" Width="500px" Height="700px" PageSize="20" ShowStatusBar="True" Skin="Sunset" EnableAJAXLoadingTemplate="True" EnableAJAX="True"> <MasterTableView DataKeyNames="CustomerID" DataSourceID="dsCustomers" AutoGenerateColumns="False" CommandItemDisplay="Top" EditMode="PopUp"> <RowIndicatorColumn> <HeaderStyle Width="20px"></HeaderStyle> </RowIndicatorColumn> <ExpandCollapseColumn> <HeaderStyle Width="20px"></HeaderStyle> </ExpandCollapseColumn> <Columns> <telerik:GridEditCommandColumn ButtonType="ImageButton" UniqueName="EditCommandColumn" HeaderStyle-Width="40px"> </telerik:GridEditCommandColumn> <telerik:GridBoundColumn DataField="CustomerID" DataType="System.Int32" HeaderText="CustomerID" ReadOnly="True" SortExpression="CustomerID" UniqueName="CustomerID" Visible="true"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="CustName" HeaderText="Customer Name" SortExpression="CustName" UniqueName="CustName" Visible="True"> </telerik:GridBoundColumn> </Columns> <EditFormSettings EditFormType="Template" CaptionFormatString='Edit Customer: {0}' CaptionDataField="CustName" InsertCaption="Add New Customer" PopUpSettings-Width="400px"> <EditColumn UniqueName="EditCommandColumn1"></EditColumn> <FormTemplate> <table id="outer_table"> <tr> <td NOWRAP> <asp:Label ID="Label1" runat="server" Text="Customer Name:" AssociatedControlID="tbCustName" /> </td> <td> <telerik:RadTextBox ID="tbCustName" runat="server" width="250px" Text='<%# Bind( "CustName" ) %>'> </telerik:RadTextBox> </td> </tr> <tr> <td nowrap style="vertical-align: top"> <asp:Label ID="Label17" runat="server" Text="Default Booking Contact:" AssociatedControlID="cbBookingContact" /> </td> <td> <telerik:RadComboBox ID="cbBookingContact" Runat="server" Skin="Sunset" DataSourceID="dsBookingContact" DataTextField="ContactName" DataValueField="ContactID" SelectedValue='<%# Bind("DefaultBookingContactID") %>' Width="255" MarkFirstMatch="True" Filter="Contains" AppendDataBoundItems="True" Text="Select a contact"> <Items> <telerik:RadComboBoxItem Value="" Text=""/> </Items> </telerik:RadComboBox> </td> </tr> <tr> <td align="left" colspan="2"> <asp:Button ID="btnUpdate" Text='<%# IIf((TypeOf(Container) is GridEditFormInsertItem), "Insert", "Update") %>' runat="server" CommandName='<%# IIf((TypeOf(Container) is GridEditFormInsertItem), "PerformInsert", "Update")%>' /> <asp:Button ID="btnCancel" Text="Cancel" runat="server" CausesValidation="False" CommandName="Cancel"></asp:Button></td> </tr> </table> </FormTemplate> </EditFormSettings> </MasterTableView> <GroupingSettings CaseSensitive="False" /> <ClientSettings> <Scrolling AllowScroll="True" UseStaticHeaders="True" /> </ClientSettings> </telerik:RadGrid> <asp:SqlDataSource ID="dsCustomers" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>" SelectCommand="SELECT Customers.CustomerID, Customers.CustName, Customers.DefaultBookingContactID FROM Customers LEFT OUTER JOIN AccountStatus ON Customers.AccountStatusID = AccountStatus.AccountStatusID ORDER BY Customers.CustCode" InsertCommand="INSERT INTO [Customers] ([CustName], [DefaultBookingContactID]) VALUES (@CustName, @CustCode, @DefaultBookingContactID)" UpdateCommand="UPDATE [Customers] SET [CustName] = @CustName, [DefaultBookingContactID] = @DefaultBookingContactID WHERE [CustomerID] = @CustomerID"> <UpdateParameters> <asp:Parameter Name="CustName" Type="String" /> <asp:Parameter Name="DefaultBookingContactID" Type="Int32" /> <asp:Parameter Name="CustomerID" Type="Int32" /> </UpdateParameters> <InsertParameters> <asp:Parameter Name="CustName" Type="String" /> <asp:Parameter Name="DefaultBookingContactID" Type="Int32" /> </InsertParameters> </asp:SqlDataSource> <asp:SqlDataSource ID="dsBookingContact" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>" SelectCommand="SELECT ContactID, ContactName, CustomerID FROM Contacts WHERE (CustomerID = @CustomerID) ORDER BY ContactName"> <SelectParameters> <asp:ControlParameter ControlID="RadGrid1" Name="CustomerID" PropertyName="SelectedValue" /> </SelectParameters> </asp:SqlDataSource> </div> </asp:Content>