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.
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.
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
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Change
<asp:Parameter Name="ApplicantID" Type="Int32" DefaultValue="2" />
To
<asp:ControlParameter ControlID="FormView1" Name="ApplicantID" PropertyName="SelectedValu
Type="Int32" />