I have a form page on the web using a FormView. There are a half dozen fields for the user to fill or select from drop downs. These get populated into the sql database with the standard sqldatasource insert statement.

However, I also want to add the current date and time and the username to the database using the same insert statement.

I only seem to be able to get it to work if the user enters the info. I want to enter programmatic info. I already have a variable defined in the aspx page that displays
(DateTime DTGNewOpened = DateTime.Now;
Response.Write(DTGNewOpened);)
I would like to have the data within the DTGNewOpened variable added to the datetime filed in the database.

I don't think I should have to do an code behind for anything this elementary, but it is driving me crazy.

Any ideas would be appreciated.

thanks,
crb

Of course you have to write code-behind. Where else would code go? Surely you're not mixing your code and HTML together in the ASPX page?

Simply modify your INSERT query itself.

exactly. You should be able to use a declared variable and include this in your INSERT statement.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.