Hopefully this'll be the last time I'll bother you.
I've set it all up and all seems okay except, when I click the button, the following happens. I don't understand why. Please refer to the couple of posts above to see what control parameters I have used but, in other areas of the page, 'SelectedValue'
works fine, just doesn't on this. Thanks. The only additional info I can give is, the dropdown stores the ID whilst displaying the text - it's the values I want across, not the text
DataBinding: 'System.Web.UI.WebControls.SqlDataSource' does not contain a property with the name 'SelectedValue'.
Description:An unhandled exception occurred during the execution of the current web request.
Please review the stack trace for more information about the error and where it originated in the code.
Exception Details:System.Web.HttpException: DataBinding: 'System.Web.UI.WebControls.SqlDataSource' does not contain a property with the name 'SelectedValue'.
Source Error:
The source code that generated this unhandled exception can only be shown when compiled in debug mode. To enable this, please follow one of the below steps, then request the URL:
1. Add a "Debug=true" directive at the top of the file that generated the error. Example:
<%@ Page Language="C#" Debug="true" %>
or:
2) Add the following section to the configuration file of your application:
<configuration>
<system.web>
<compilation debug="true"/>
</system.web>
</configuration>
Note that this second technique will cause all files within a given application to be compiled in debug mode. The first technique will cause only that particular file to be compiled in debug mode.
Important: Running applications in debug mode does incur a memory/performance overhead. You should make sure that an application has debugging disabled before deploying into production scenario.
Stack Trace:
[HttpException (0x80004005): DataBinding: 'System.Web.UI.WebControls.SqlDataSource' does not contain a property with the name 'SelectedValue'.] System.Web.UI.DataBinder.GetPropertyValue(Object container, String propName) +8660197 System.Web.UI.DataBinder.Eval(Object container, String[] expressionParts) +92 System.Web.UI.DataBinder.Eval(Object container, String expression) +106 System.Web.UI.WebControls.ControlParameter.Evaluate(HttpContext context, Control control) +211 System.Web.UI.WebControls.Parameter.UpdateValue(HttpContext context, Control control) +47 System.Web.UI.WebControls.ParameterCollection.UpdateValues(HttpContext context, Control control) +114 System.Web.UI.WebControls.ParameterCollection.GetValues(HttpContext context, Control control) +41 System.Web.UI.WebControls.SqlDataSourceView.InitializeParameters(DbCommand command, ParameterCollection parameters, IDictionary exclusionList) +264 System.Web.UI.WebControls.SqlDataSourceView.ExecuteInsert(IDictionary values) +104 System.Web.UI.WebControls.SqlDataSource.Insert() +16 _Default.CreateJob_Click1(Object sender, EventArgs e) +19 System.Web.UI.WebControls.Button.OnClick(EventArgs e) +111 System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +110 System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10 System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13 System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565
If you would not be able to make it work this way, set them as just parameters (not control parameter) and set them programmatically in Inserting event of SQLDataSource.
Beware of bugs in the above code; I have only proved it correct, not tried it. (Donald Knuth)
And removed the reference to propertyname but, it doesn't like it - please help. Thanks
Type 'System.Web.UI.WebControls.Parameter' does not have a public property named 'ControlID'.
Source Error:
Line 512: <asp:ControlParameter ControlID="ClientContact" Name="ClContactID" Line 513: PropertyName="SelectedValue" Type="Int32" /> Line 514: <asp:Parameter ControlID="StartDate" Name="StartDate" Line 515: /> Line 516: <asp:Parameter="RequestedDate" Name="RequestedDate"
I also tried, removing the start date, required date and estimated date completely. The same error comes up when the button is clicked.
Do I keep removing them all until I find one that works or fails? How do I get it to fulfill the variables on the INSERT store procedure without having the insert parameters set to dropdowns, textboxes, etc on the page?
Do you think it might be a problem with the stored procedure instead? It is shown at the bottom of page 1 of this thread.
Sorry, try starting a new thread with the problem and provide as much details as possible. I plan to do a little break in answering questions right now and finish watching some training videos.
Beware of bugs in the above code; I have only proved it correct, not tried it. (Donald Knuth)
mattlightbou...
Member
3 Points
53 Posts
Re: Inserting data into SQL Tables from ASP Form
Dec 22, 2009 02:06 PM|LINK
Hopefully this'll be the last time I'll bother you.
I've set it all up and all seems okay except, when I click the button, the following happens. I don't understand why. Please refer to the couple of posts above to see what control parameters I have used but, in other areas of the page, 'SelectedValue' works fine, just doesn't on this. Thanks. The only additional info I can give is, the dropdown stores the ID whilst displaying the text - it's the values I want across, not the text
DataBinding: 'System.Web.UI.WebControls.SqlDataSource' does not contain a property with the name 'SelectedValue'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.Exception Details: System.Web.HttpException: DataBinding: 'System.Web.UI.WebControls.SqlDataSource' does not contain a property with the name 'SelectedValue'.
Source Error:
The source code that generated this unhandled exception can only be shown when compiled in debug mode. To enable this, please follow one of the below steps, then request the URL: 1. Add a "Debug=true" directive at the top of the file that generated the error. Example: <%@ Page Language="C#" Debug="true" %> or: 2) Add the following section to the configuration file of your application: <configuration> <system.web> <compilation debug="true"/> </system.web> </configuration> Note that this second technique will cause all files within a given application to be compiled in debug mode. The first technique will cause only that particular file to be compiled in debug mode. Important: Running applications in debug mode does incur a memory/performance overhead. You should make sure that an application has debugging disabled before deploying into production scenario.Stack Trace:
mattlightbou...
Member
3 Points
53 Posts
Re: Inserting data into SQL Tables from ASP Form
Dec 22, 2009 04:18 PM|LINK
Please help, cannot find the answer to this - been on this for ages, still can't figure it out. Why does the above error happen with this:
<asp:SqlDataSource ID="JobData" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>" InsertCommand="InsertJob" InsertCommandType="StoredProcedure" OnInserted="JobData_Inserted" SelectCommand="SELECT * FROM [Job]"> <InsertParameters> <asp:ControlParameter ControlID="Orientation" Name="JobStatusID" PropertyName="SelectedValue" Type="Int32" /> <asp:ControlParameter ControlID="ProductName" Name="JobDesc" PropertyName="Text" Type="String" /> <asp:ControlParameter ControlID="CompanyName" Name="CompanyID" PropertyName="SelectedValue" Type="Int32" /> <asp:ControlParameter ControlID="CompLocation" Name="LocationID" PropertyName="SelectedValue" Type="Int32" /> <asp:ControlParameter ControlID="StudioContact" Name="HandlerID" PropertyName="SelectedValue" Type="Int32" /> <asp:ControlParameter ControlID="ClientName" Name="ClientID" PropertyName="SelectedValue" Type="Int32" /> <asp:ControlParameter ControlID="CL_Department" Name="DepartmentID" PropertyName="SelectedValue" Type="Int32" /> <asp:ControlParameter ControlID="ClientContact" Name="ClContactID" PropertyName="SelectedValue" Type="Int32" /> <asp:ControlParameter ControlID="StartDate" Name="StartDate" PropertyName="text" Type="datetime" /> <asp:ControlParameter ControlID="RequestedDate" Name="RequestedDate" PropertyName="selectedvalue" Type="datetime" /> <asp:ControlParameter ControlID="Estimated" Name="EstimatedDate" PropertyName="selectedvalue" Type="datetime" /> <asp:ControlParameter Direction ="Output" Name="JobID" Type="Int32" /> </InsertParameters> </asp:SqlDataSource> <asp:Button ID="CreateJob" runat="server" Text="Create Job" />Why does it not know about PropertyName="SelectedValue"? I have it on every single dropdown and it works everywhere fine.
The button has a stored procedure which is at the bottom of page 1 or the top of this page of the thread.
Your help is so needed and appreciated!
Thanks
Matt
Naom
All-Star
36004 Points
7901 Posts
Re: Inserting data into SQL Tables from ASP Form
Dec 22, 2009 04:26 PM|LINK
Are RequestedDate and Estimated the drop down?
If you would not be able to make it work this way, set them as just parameters (not control parameter) and set them programmatically in Inserting event of SQLDataSource.
(Donald Knuth)
Visit my blog
Microsoft Community Contributor 2011-12
mattlightbou...
Member
3 Points
53 Posts
Re: Inserting data into SQL Tables from ASP Form
Dec 22, 2009 04:45 PM|LINK
Thanks for your reply.
I tried it on startdate, requireddate and estimateddate - changing it from ControlParameter to:
<asp:Parameter ControlID="StartDate" Name="StartDate" /> <asp:Parameter="RequestedDate" Name="RequestedDate" /> <asp:Parameter="Estimated" Name="EstimatedDate" /> <asp:Parameter Direction ="Output" Name="JobID" Type="Int32" /> </InsertParameters> </asp:SqlDataSource>And removed the reference to propertyname but, it doesn't like it - please help. Thanks
Type 'System.Web.UI.WebControls.Parameter' does not have a public property named 'ControlID'.
Source Error:
mattlightbou...
Member
3 Points
53 Posts
Re: Inserting data into SQL Tables from ASP Form
Dec 22, 2009 04:47 PM|LINK
oops, I know I missed off ControlID in my rely. Tried with, without, still can't work it out. What was wrong with my original you think?
Thanks again
Matt
Naom
All-Star
36004 Points
7901 Posts
Re: Inserting data into SQL Tables from ASP Form
Dec 22, 2009 04:52 PM|LINK
Instead of this
<asp:ControlParameter ControlID="ClientContact" Name="ClContactID"
Line 513: PropertyName="SelectedValue" Type="Int32" />
Try
<asp:Parameter Name="ClContactID" Type="Int32" />
for each of the misbehaving parameters (use the name of the parameter for your date parameters)
(Donald Knuth)
Visit my blog
Microsoft Community Contributor 2011-12
mattlightbou...
Member
3 Points
53 Posts
Re: Inserting data into SQL Tables from ASP Form
Dec 22, 2009 04:54 PM|LINK
I also tried, removing the start date, required date and estimated date completely. The same error comes up when the button is clicked.
Do I keep removing them all until I find one that works or fails? How do I get it to fulfill the variables on the INSERT store procedure without having the insert parameters set to dropdowns, textboxes, etc on the page?
Do you think it might be a problem with the stored procedure instead? It is shown at the bottom of page 1 of this thread.
thanks again
Naom
All-Star
36004 Points
7901 Posts
Re: Inserting data into SQL Tables from ASP Form
Dec 22, 2009 05:08 PM|LINK
Sorry, try starting a new thread with the problem and provide as much details as possible. I plan to do a little break in answering questions right now and finish watching some training videos.
(Donald Knuth)
Visit my blog
Microsoft Community Contributor 2011-12
Jian Kang - ...
All-Star
33132 Points
2465 Posts
Re: Inserting data into SQL Tables from ASP Form
Dec 23, 2009 02:42 AM|LINK
I would suggest you define the insert parameters via the configuration wizard.
Please see:
Inserting, Updating, and Deleting Data with the SqlDataSource
http://www.asp.net/learn/data-access/tutorial-49-vb.aspx
Please remove the RETURN_VALUE parameter and change the output parameter’s direction to Output.
Microsoft Online Community Support
Please remember to mark the replies as answers if they help and unmark them if they provide no help.