View Single Post
  #4 (permalink)  
Old July 27th, 2010, 12:27 PM
mashype mashype is offline
Authorized User
 
Join Date: Jan 2009
Posts: 25
Thanks: 3
Thanked 1 Time in 1 Post
Default

Sorry, but I am just trying to get a cascading dropdown item (basically what is on the site http://www.asp.net/ajax/ajaxcontrolt...CCDWithDB.aspx) to bind back to a MSSQL database. I have three relevanttables that I am pulling from

tblLTGoals - Which is the first level of the drop down
tblSTGoals - Which is the second level of the drop down
tblProduction - Which is where I want to store what ends up in the second dropdown.

You say that I am missing code that returns the second level content in the GetDropDownContents method. I have a feeling this is exactly what I am missing that is causing my errors. Is there any help you can provide in how I complete that code?

Here is the cleaned up code.
Code:
<%@PageLanguage="C#"AutoEventWireup="true"CodeFile="Index.aspx.cs"Inherits="Anthem_Admin_Index" %>
<%@Registerassembly="AjaxControlToolkit"namespace="AjaxControlToolkit"tagprefix="asp" %>
<!DOCTYPEhtmlPUBLIC"-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<htmlxmlns="http://www.w3.org/1999/xhtml">
<headrunat="server">
</head>
<body>
<formid="form1"runat="server">
<div>
<asp:ScriptManagerID="ScriptManager1"runat="server"/>
<asp:FormViewID="FormView1"runat="server"DataKeyNames="ProductionID"DataSourceID="Tasks"EnableModelValidation="True"DefaultMode="Insert">
<InsertItemTemplate>
LTGoal:
<asp:DropDownListID="DropDownList1"runat="server"AutoPostBack="True"DataSourceID="LT"DataTextField="LTGoal"DataValueField="LTGoalID">
</asp:DropDownList>
<br/>
STGoal:
<asp:DropDownListID="DropDownList2"runat="server"DataSourceID="ST"DataTextField="SpecificTarget"DataValueField="SpecTargetID"SelectedValue='<%# Bind("STGoal") %>'>
</asp:DropDownList>
<asp:CascadingDropDownID="DropDownList2_CascadingDropDown"runat="server"Enabled="True"ServiceMethod="GetDropDownContents"TargetControlID="DropDownList2"UseContextKey="True"Category="Tasks"EmptyText="Select LT Goal">
</asp:CascadingDropDown>
<br/>
Comments:
<asp:TextBoxID="CommentsTextBox"runat="server"Text='<%# Bind("Comments") %>'/>
<br/>
<asp:LinkButtonID="InsertButton"runat="server"CausesValidation="True"CommandName="Insert"Text="Insert"/>
&nbsp;<asp:LinkButtonID="InsertCancelButton"runat="server"CausesValidation="False"CommandName="Cancel"Text="Cancel"/>
<asp:SqlDataSourceID="LT"runat="server"ConnectionString="<%$ ConnectionStrings:anthemprodConnectionString %>"SelectCommand="SELECT [LTGoalID], [LTGoal] FROM [TblGoalsLT]">
</asp:SqlDataSource>
<asp:SqlDataSourceID="ST"runat="server"ConnectionString="<%$ ConnectionStrings:anthemprodConnectionString %>"SelectCommand="SELECT [SpecTargetID], [SpecificTarget] FROM [TblGoalsST] WHERE ([MeasureID] = @MeasureID)">
<SelectParameters>
<asp:ControlParameterControlID="DropDownList1"Name="MeasureID"PropertyName="SelectedValue"Type="Int32"/>
</SelectParameters>
</asp:SqlDataSource>
</InsertItemTemplate>
</asp:FormView>
<asp:SqlDataSourceID="Tasks"runat="server"ConnectionString="<%$ ConnectionStrings:anthemprodConnectionString %>"InsertCommand="INSERT INTO [TblProduction] ([LTGoal], [STGoal], [Comments]) VALUES (@LTGoal, @STGoal, @Comments)">
<InsertParameters>
<asp:ParameterName="LTGoal"Type="Int32"/>
<asp:ParameterName="STGoal"Type="Int32"/>
<asp:ParameterName="Comments"Type="String"/>
</InsertParameters>
</asp:SqlDataSource>
</div>
</form>
</body>
</html>