I have a formview which is tied up to a LINQ datasource, both of which are created in the markup (aspx) page. I am able to insert records to my database without issue.
The problem: I would like to timestamp the records as they are written into the database.
A basic look at what my formview and datasource looks like:
<asp:LinqDataSource id="linqdatasource1" runat="server" ContextTypeName="datacontext1" TableName="demotable" EnableInsert="true"></asp:LinqDataSource>
<asp:FormView ID="formview1" runat="server" DataSourceID="linqdatasource1" DataKeyName="id" DefaultMode="insert">
<InsertTemplate>
<asp:TextBox id="textbox1" runat="server" text='<%#Bind("field1")' />
<asp:Button id="button1" runat="server" CommandName="Insert" Text="Insert Record" />
</InsertTemplate>
</asp:FormView>
Now, assume my table (demotable) has two fields, "field1 (nvarchar(50))" and "timestamp (datetime)". On insert of a record, I'd like to get a timestamp (i.e. System.DateTime.Now()) of the time the record went in. How do I go about adding this extra information to my insert when it isn't explicitly part of the user's input from the FormView?