CodeVerge.Net Beta


   Explore    Item Entry   Register  Login  
Microsoft News
Asp.Net Forums
IBM Software
Borland Forums
Adobe Forums
Novell Forums

ASP.NET Web Hosting
ASP.NET MVC Ready – 3 Months Free and Free Setup



Can Reply:  No Members Can Edit: No Online: Yes
Zone: > NEWSGROUP > Asp.Net Forum > starter_kits_and_source_projects.classifieds_starter_kit Tags:
Item Type: NewsGroup Date Entered: 6/10/2006 10:11:39 AM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
NR
XPoints: N/A Replies: 2 Views: 45 Favorited: 0 Favorite
3 Items, 1 Pages 1 |< << Go >> >|
yhhaw
Asp.Net User
dropdownlist6/10/2006 10:11:39 AM

0

Hi,

I am testing to create a data entry form to insert data into table.  I have two dropdownlist in my data entry form.  The first one (called category) is to select category, the second one (called sub-category) is depends on the selection of first dropdownlist, where the list of sub-category shown is filtered by Cat_ID.  When I run it, I have the following message:

"Databinding methods such as Eval(), XPath(), and Bind() can only be used in the context of a databound control."

Can anybody help?

Here is my source code:

<%

@ Page Language="VB" %>

<!

DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<

script runat="server">

</

script>

<

html xmlns="http://www.w3.org/1999/xhtml" >

<

head runat="server">

<title>Untitled Page</title>

</

head>

<

body>

<form id="form1" runat="server">

<div>

<asp:FormView ID="FormView1" runat="server" AllowPaging="True" DataKeyNames="Ad_ID"

DataSourceID="SqlDataSource1">

<EditItemTemplate>

Ad_ID:

<asp:Label ID="Ad_IDLabel1" runat="server" Text='<%# Eval("Ad_ID") %>'></asp:Label><br />

Cat_ID:

<asp:TextBox ID="Cat_IDTextBox" runat="server" Text='<%# Bind("Cat_ID") %>'>

</asp:TextBox><br />

Sub_ID:

<asp:TextBox ID="Sub_IDTextBox" runat="server" Text='<%# Bind("Sub_ID") %>'>

</asp:TextBox><br />

<asp:LinkButton ID="UpdateButton" runat="server" CausesValidation="True" CommandName="Update"

Text="Update">

</asp:LinkButton>

<asp:LinkButton ID="UpdateCancelButton" runat="server" CausesValidation="False" CommandName="Cancel"

Text="Cancel">

</asp:LinkButton>

</EditItemTemplate>

<InsertItemTemplate>

Cat_ID:

<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True" DataSourceID="SqlDataSource1"

DataTextField="Cat_Name" DataValueField="Cat_ID" SelectedValue='<%# Bind("Cat_ID") %>'>

</asp:DropDownList><asp:SqlDataSource ID="SqlDataSource1" runat="server" ConflictDetection="CompareAllValues"

ConnectionString="<%$ ConnectionStrings:ConnectionString %>" DeleteCommand="DELETE FROM [Cat] WHERE [Cat_ID] = @original_Cat_ID AND [Cat_Name] = @original_Cat_Name"

InsertCommand="INSERT INTO [Cat] ([Cat_Name]) VALUES (@Cat_Name)" OldValuesParameterFormatString="original_{0}"

SelectCommand="SELECT [Cat_ID], [Cat_Name] FROM [Cat]" UpdateCommand="UPDATE [Cat] SET [Cat_Name] = @Cat_Name WHERE [Cat_ID] = @original_Cat_ID AND [Cat_Name] = @original_Cat_Name">

<DeleteParameters>

<asp:Parameter Name="original_Cat_ID" Type="Int32" />

<asp:Parameter Name="original_Cat_Name" Type="String" />

</DeleteParameters>

<UpdateParameters>

<asp:Parameter Name="Cat_Name" Type="String" />

<asp:Parameter Name="original_Cat_ID" Type="Int32" />

<asp:Parameter Name="original_Cat_Name" Type="String" />

</UpdateParameters>

<InsertParameters>

<asp:Parameter Name="Cat_Name" Type="String" />

</InsertParameters>

</asp:SqlDataSource>

<br />

Sub_ID:

<asp:DropDownList ID="DropDownList2" runat="server" AutoPostBack="True" DataSourceID="ObjectDataSource1"

DataTextField="Sub_Name" DataValueField="Sub_ID" SelectedValue='<%# Bind("Sub_ID") %>'>

</asp:DropDownList><asp:ObjectDataSource ID="ObjectDataSource1" runat="server" DeleteMethod="Delete"

InsertMethod="Insert" OldValuesParameterFormatString="original_{0}" SelectMethod="GetData"

TypeName="DataSet1TableAdapters.Sub_CatTableAdapter" UpdateMethod="Update">

<DeleteParameters>

<asp:Parameter Name="Original_Sub_ID" Type="Int32" />

</DeleteParameters>

<UpdateParameters>

<asp:Parameter Name="Cat_ID" Type="Int32" />

<asp:Parameter Name="Sub_Name" Type="String" />

<asp:Parameter Name="Original_Sub_ID" Type="Int32" />

</UpdateParameters>

<SelectParameters>

<asp:ControlParameter ControlID="DropDownList1" Name="Cat_ID" PropertyName="SelectedValue"

Type="Int32" />

</SelectParameters>

<InsertParameters>

<asp:Parameter Name="Cat_ID" Type="Int32" />

<asp:Parameter Name="Sub_Name" Type="String" />

</InsertParameters>

</asp:ObjectDataSource>

<br />

<asp:LinkButton ID="InsertButton" runat="server" CausesValidation="True" CommandName="Insert"

Text="Insert"></asp:LinkButton>

<asp:LinkButton ID="InsertCancelButton" runat="server" CausesValidation="False" CommandName="Cancel"

Text="Cancel"></asp:LinkButton>

</InsertItemTemplate>

<ItemTemplate>

Ad_ID:

<asp:Label ID="Ad_IDLabel" runat="server" Text='<%# Eval("Ad_ID") %>'></asp:Label><br />

Cat_ID:

<asp:Label ID="Cat_IDLabel" runat="server" Text='<%# Bind("Cat_ID") %>'></asp:Label><br />

Sub_ID:

<asp:Label ID="Sub_IDLabel" runat="server" Text='<%# Bind("Sub_ID") %>'></asp:Label><br />

<asp:LinkButton ID="EditButton" runat="server" CausesValidation="False" CommandName="Edit"

Text="Edit"></asp:LinkButton>

<asp:LinkButton ID="DeleteButton" runat="server" CausesValidation="False" CommandName="Delete"

Text="Delete"></asp:LinkButton>

<asp:LinkButton ID="NewButton" runat="server" CausesValidation="False" CommandName="New"

Text="New"></asp:LinkButton>

</ItemTemplate>

</asp:FormView>

<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConflictDetection="CompareAllValues"

ConnectionString="<%$ ConnectionStrings:ConnectionString %>" DeleteCommand="DELETE FROM [Ads] WHERE [Ad_ID] = @original_Ad_ID AND [Cat_ID] = @original_Cat_ID AND [Sub_ID] = @original_Sub_ID"

InsertCommand="INSERT INTO [Ads] ([Cat_ID], [Sub_ID]) VALUES (@Cat_ID, @Sub_ID)"

OldValuesParameterFormatString="original_{0}" SelectCommand="SELECT [Ad_ID], [Cat_ID], [Sub_ID] FROM [Ads]"

UpdateCommand="UPDATE [Ads] SET [Cat_ID] = @Cat_ID, [Sub_ID] = @Sub_ID WHERE [Ad_ID] = @original_Ad_ID AND [Cat_ID] = @original_Cat_ID AND [Sub_ID] = @original_Sub_ID">

<DeleteParameters>

<asp:Parameter Name="original_Ad_ID" Type="Int32" />

<asp:Parameter Name="original_Cat_ID" Type="Int32" />

<asp:Parameter Name="original_Sub_ID" Type="Int32" />

</DeleteParameters>

<UpdateParameters>

<asp:Parameter Name="Cat_ID" Type="Int32" />

<asp:Parameter Name="Sub_ID" Type="Int32" />

<asp:Parameter Name="original_Ad_ID" Type="Int32" />

<asp:Parameter Name="original_Cat_ID" Type="Int32" />

<asp:Parameter Name="original_Sub_ID" Type="Int32" />

</UpdateParameters>

<InsertParameters>

<asp:Parameter Name="Cat_ID" Type="Int32" />

<asp:Parameter Name="Sub_ID" Type="Int32" />

</InsertParameters>

</asp:SqlDataSource>

</div>

</form>

</

body>

</

html>
paggy4u
Asp.Net User
Re: dropdownlist6/14/2006 2:38:58 AM

0

Hello,

I found great 10 Data Access Tutorials  today. One of  the great tutorial just announced is totally as per your requirement.

In fact all this 10 tutorials are great, but this one matches your exact requirement.

Pl. read it here.....
http://www.asp.net/learn/dataaccess/tutorial08cs.aspx?tabid=63

Thanks

Paggy4u


Paggy4u
-----------------------------------------
An Unblinking eye on IronRuby,Asp.Net and .Net
http://ironruby.blogspot.com/
yhhaw
Asp.Net User
Re: dropdownlist6/14/2006 12:40:32 PM

0

Hello Paggy4u,

Thanks for your prompt and hints. 

I am sorry to tell you that this is not exactly what I am looking for (in fact, I have seen the tutorial before).  I just wanted the two dependent dropdownlist to be appeared in my data entry form, and the value that selected must be able to bind to one of my table in database after clicking "insert".

Please help.

3 Items, 1 Pages 1 |< << Go >> >|


Free Download:

Books:
Programming ASP.NET: Building Web Applications and Services with ASP.NET 2.0 Authors: Jesse Liberty, Dan Hurwitz, Pages: 930, Published: 2005
Professional ASP.NET 2.0 Authors: Bill Evjen, Scott Hanselman, Farhan Muhammad, Srinivasa Sivakumar, Devin Rader, Pages: 1253, Published: 2005
Beginning InfoPath 2003 Authors: F. Scott Barker, Pages: 384, Published: 2005
FrontPage 2003 All-in-One Desk Reference For Dummies: all-in-one desk reference Authors: John Paul Mueller, Pages: 792, Published: 2004
ASP.NET 2.0 All-In-One Desk Reference For Dummies: all-in-one desk reference for dummies Authors: Doug Lowe, Jeff Cogswell, Ken Cox, Pages: 910, Published: 2006
Visual Web Developer 2005 Express Edition For Dummies Authors: Alan Simpson, Pages: 358, Published: 2005
Professional ASP.NET 3.5: In C# and VB Authors: Bill Evjen, Scott Hanselman, Devin Rader, Pages: 1673, Published: 2008
ASP.NET 2.0 Cookbook Authors: Michael A. Kittel, Geoffrey T. Leblond, Pages: 989, Published: 2005
ACT! 2007 For Dummies Authors: Karen S. Fredricks, Pages: 392, Published: 2006
AutoCAD 2004 Instructor: A Student Guide to Complete Coverage of AutoCAD's Commands and Features Authors: James A. Leach, Pages: 1344, Published: 2003

Web:
DropDownList Class (System.Web.UI.WebControls) Represents a control that allows the user to select a single item from a drop- down list.
DropDownList Web Server Control The DropDownList Web server control enables users to select from a ... The DropDownList control is similar to the ListBox Web server control. ...
ASP.NET DropDownList Control The DropDownList control is used to create a drop-down list. Each selectable item in a DropDownList control is defined by a ListItem element! ...
Working with DropDownList and ListBox Controls in ASP.NET In this article we'll see how to use DropDownList and ListBox Web controls to display data in various formats.
DropDownList in ASP .Net Dec 27, 2004 ... Explains how to use DropDownList in ASP .Net with samples for databinding.
Drop-down list - Wikipedia, the free encyclopedia A drop-down list is a user interface control GUI element similar to a list box which allows the user to choose one value from a list. When a drop-down list ...
Drop Down List Generator Examples of popular uses for the drop down list: ... Click Here to Get a Drop Down List ...
4GuysFromRolla.com - Adding a DropDownList to an Editable DataGrid This article, by Matthew Rouse, examines how to bind Web controls other than the TextBox Web control to the DataGrid Web control for editing purposes.
CodeProject: AJAX DropDownList. Free source code and programming help Custom DropdownList that utilizes AJAX to populate its content and implements Observer pattern to participate in dependent dropdownlist chains.; ...
Multilevel Drop Down List - Samples Multilevel Drop Down List. Deluxe menu can contain as many rows as you wish. To create a multilevel drop down list add '$' symbol before an item text to ...

Videos:
Drop Down List in Excel http://www.contextures.com/xlDataVal01.html Select from a drop down list on the Excel worksheet. Details at http://www.contextures.com/xlDataVal01.ht...
Microsoft Excel 2007: How to Create a Drop Down List In this video you will learn how to create a drop down list using Data Validation in Microsoft Excel 2007. If you would like to learn more about M...
Asp.Net (VB.Net) DataReader DropDownList Inline Page Model - Shalvin Asp.Net (VB.Net) DataReader DropDownList Inline Page Model - Shalvin
Excel Magic Trick #139: HYPERLINK function & Drop Down List See how to use Data Validation List Drop-down and the hyperlink function to create a list of hyper links. See how to link to a web site or a cell on ...
Creating a drop down list w/ a rubric via eWalk This tutorial is designed to instruct individuals on how to create a drop down element in the web based eWalk application.
Popular um DropDownList em C# Aprenda a Popular um DropDownList em C#
Creating a Drop down list in eWalk Today you will learn how to create a drop down menu in eWalk and add it to a template
C# Preencher um DropDownList Video ensinando como preencher um DropDown
DropDownList não carrega DropDown list não carrega.












how do you create a admin account

how to make multi language classified site

admin panel - textbox alignment

change dollar ($) sign to a pound (£) sign

looking for most recent version of classified starter kit

my site don't look right in internet explorer 7

i dont want the page full reload when user choose another picture.

uploaded images are not deleted.

show your working classified kit here.

xml feed to classifieds

where is the class adsdataadapter implemented in the code?

new website

any object diagrams for classifieds project.

controls/featuredad.asdx

security problem

first asp.net classifieds kit upload to server.. help

running aspnet_regsql.exe for classified database.

classifieds starter kit

performance improvement

search.aspx - add sub-category column

required approval when editing ads

code snippet i used in love2trade.com to send an email to me on any exception

adding icon to category

the files '/app_code/bll/locations.cs' and '/app_code/bll/sitesettings.vb' use a different language,

application_start

anyway to only display main catagory on front page?

i have successfuly extended the starterkit, including more fields in ad, createuserwizard, etc, read more !

document

sending mails problem

how to host classfields startup on your own server.

   
  Privacy | Contact Us
All Times Are GMT