Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 3.5 > ASP.NET 3.5 Basics
Password Reminder
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
ASP.NET 3.5 Basics If you are new to ASP or ASP.NET programming with version 3.5, this is the forum to begin asking questions. Please also see the Visual Web Developer 2008 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 3.5 Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old May 25th, 2009, 12:42 PM
Authorized User
Join Date: Jan 2009
Posts: 25
Thanks: 3
Thanked 1 Time in 1 Post
Default Cascading dropdowns bound to MSSQL

I have seen several threads on this issue and can not seem to get any of it to work for me. I have two drop downs on a form that cascade down for data entry. Basically they are a 'Long Term Goal', and then a 'Short Term Goal' based on the first drop down. I keep getting this error every time I try to bind the data to the SQL file.

When I try to databind the second dropdown, I get this error 'Databinding methods such as Eval(), XPath(), and Bind() can only be used in the ......'

I have tried turning the 'EnableView State' on and off with no luck.

Here are my dropdown codes:

<asp:SqlDataSourceID="LT"runat="server"ConnectionString="<%$ ConnectionStrings:anthemprodConnectionString %>"SelectCommand="SELECT [LTGoalID], [LTGoal] FROM [TblGoalsLT]">
<asp:SqlDataSourceID="ST"runat="server"ConnectionString="<%$ ConnectionStrings:anthemprodConnectionString %>"SelectCommand="SELECT SpecTargetID, SpecificTarget, MeasureID FROM TblGoalsST WHERE (MeasureID = @SpecTargetID)">

Is there some C# code bihind I am not understanding, or is there something in the dropdown setup that I am missing?

Any help would be GREATLY appreicated!
  #2 (permalink)  
Old May 25th, 2009, 05:24 PM
Lee Dumond's Avatar
Wrox Author
Points: 4,942, Level: 29
Points: 4,942, Level: 29 Points: 4,942, Level: 29 Points: 4,942, Level: 29
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Jan 2008
Location: Decatur, IL, USA.
Posts: 923
Thanks: 12
Thanked 166 Times in 162 Posts

Have you considered using the CascadindDropDown AJAX control? This would be easier, in addition to avoiding the postback to populate the second list.

Visit my blog at http://leedumond.com
Follow me on Twitter: http://twitter.com/LeeDumond

if (this.PostHelpedYou)
  #3 (permalink)  
Old July 24th, 2010, 01:41 AM
Authorized User
Join Date: Jan 2009
Posts: 25
Thanks: 3
Thanked 1 Time in 1 Post
Default Still having problems

I actualle gave up on this for a while, but still want to get this done. I am trying to incorporate the AJAX control but having problems..

Here is the code I have:
<%@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">
<asp:DropDownListID="DropDownList2"runat="server"DataSourceID="ST"DataTextField="SpecificTarget"DataValueField="SpecTargetID"SelectedValue='<%# Bind("STGoal") %>'>
<asp:CascadingDropDownID="DropDownList2_CascadingDropDown"runat="server"Enabled="True"ServiceMethod="GetDropDownContents"TargetControlID="DropDownList2"UseContextKey="True"Category="Tasks"EmptyText="Select LT Goal">
<asp:TextBoxID="CommentsTextBox"runat="server"Text='<%# Bind("Comments") %>'/>
<asp:SqlDataSourceID="LT"runat="server"ConnectionString="<%$ ConnectionStrings:anthemprodConnectionString %>"SelectCommand="SELECT [LTGoalID], [LTGoal] FROM [TblGoalsLT]">
<asp:SqlDataSourceID="ST"runat="server"ConnectionString="<%$ ConnectionStrings:anthemprodConnectionString %>"SelectCommand="SELECT [SpecTargetID], [SpecificTarget] FROM [TblGoalsST] WHERE ([MeasureID] = @MeasureID)">
<asp:SqlDataSourceID="Tasks"runat="server"ConnectionString="<%$ ConnectionStrings:anthemprodConnectionString %>"DeleteCommand="DELETE FROM [TblProduction] WHERE [ProductionID] = @ProductionID"InsertCommand="INSERT INTO [TblProduction] ([LTGoal], [STGoal], [Comments]) VALUES (@LTGoal, @STGoal, @Comments)"SelectCommand="SELECT [ProductionID], [LTGoal], [STGoal], [Comments] FROM [TblProduction]"UpdateCommand="UPDATE [TblProduction] SET [LTGoal] = @LTGoal, [STGoal] = @STGoal, [Comments] = @Comments WHERE [ProductionID] = @ProductionID">

I have been able to get the dropdowns to display correctly, but when I try to bind the second dropdown, I still get that databinding error. Am I not setting something up right with the AJAX control?
  #4 (permalink)  
Old August 6th, 2010, 06:18 AM
Registered User
Join Date: Aug 2010
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default thank

thanks for sharing nice information

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Cascading dropwonds bound to MSSQL mashype ASP.NET 3.5 Basics 0 May 25th, 2009 12:42 PM
MSSQL 2005 and MSSQL 2000 tiredcat Visual Basic 2005 Basics 0 April 9th, 2007 12:56 AM
Dynamic Dropdowns jasmine_vj Classic ASP Basics 2 April 17th, 2006 12:47 PM
Cascading dropdowns-Client Callbacks spriya18 ASP.NET 2.0 Professional 0 December 29th, 2005 02:29 PM

All times are GMT -4. The time now is 08:28 PM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.