sql insert using a parameter whose value is obtained from the selected value of a dro

dilipv

New member
Joined
Feb 5, 2008
Messages
4
Programming Experience
Beginner
Actually I wanted an sql insert using a parameter whose value is obtained from the selected value of a dropdown list inside of a form view.

My approach is:

My SqlDataSource has an insert commant like so (partial code)
VB.NET:
InsertCommand=      "INSERT INTO [table_name] (
[field_name1],
[field_name2]
) VALUES (
@ field_name1,
@ field_name2)

I have an insert parameter as follows
HTML:
<InsertParameters>
<asp:ControlParameter Name="field_name1" ControlID="dropdown_control_name" PropertyName="SelectedValue" />
</InsertParameters>

The error I get is:
Could not find control ' dropdown_control_name ' in ControlParameter ' field_name1'.
-------------------
I think that the problem is that it cannot find my dropdown control.
So I also tried the following insertparameter:

HTML:
<asp:ControlParameter Name=" field_name1" ControlID="<%# Me.dropdown_control_name.clientID %>" PropertyName="SelectedValue" />

Which gave me the following error:
Databinding expressions are only supported on objects that have a DataBinding event. System.Web.UI.WebControls.ControlParameter does not have a DataBinding event.

Any help is much appreciated. I am just now learning asp 2.0


Thank you
Jitesh
Programmer
 
Last edited by a moderator:
Back
Top