Link to home
Start Free TrialLog in
Avatar of JonoBB
JonoBB

asked on

Default value for insert parameter

Hi,

I have two detailsview on a single page, DetailsView1 and DetailsView2.

DetailsView1 is based on a recordset as follows:

tblApplication
----------------
ApplicantID (PK)
ApplicationName


DetailsView2 is based on a recordset as follows:

tblApplicationNote
-------------------
ApplicationNoteID (PK)
ApplicantID (FK from tblApplication)
NoteDetails
NoteDate


Now, I would like to insert a new record into tblAppllicationNote using DetailsView2, and I have assigned the parameters as follows:
           
<InsertParameters>
                <asp:Parameter Name="ApplicantID" Type="Int32" DefaultValue="2" />
                <asp:Parameter Name="NoteDetails" Type="String" />
                <asp:Parameter Name="NoteDate" Type="DateTime" />
</InsertParameters>


As you can see, I have assigned a default value of "2" for ApplicantID to test that the insert command works, which it does.

However, I would like to set the default value of ApplicantID to be the currentvalue of DetailsView1; i.e. as we page through the recordset in DetailsView1, then inserting a note in DetailsView2 will happen correctly.

Thanks for any help that you can provide.
Avatar of JonoBB
JonoBB

ASKER

I seem to be answering these faster than anyone else...

Change
                <asp:Parameter Name="ApplicantID" Type="Int32" DefaultValue="2" />

To

                <asp:ControlParameter ControlID="FormView1" Name="ApplicantID" PropertyName="SelectedValue"
                    Type="Int32" />
Hi JonoBB,

Please, when you get a chance, close this question.  

To do so, post a zero-point question in https://www.experts-exchange.com/Community_Support/

Subject: Moderator Please PAQ
Body: Please PAQ this question, I answered it myself
https://www.experts-exchange.com/questions/21793362/Default-value-for-insert-parameter.html

Thank you!

-- Jason
ASKER CERTIFIED SOLUTION
Avatar of GranMod
GranMod

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial