Solved

Edit date in edit view asp.net mvc

Posted on 2011-03-01
3
481 Views
Last Modified: 2012-05-11
Hi,

I am using Linq to Sql. I am inserting data in the table using create view. Date column have default value = getdate() in the sql server database. So automatically, it will insert the server date.

But problem is, when I update the data using edit view and save view , it will not update the date in the table.

How to update the date on every insert in asp.net mvc.

Thanks
0
Comment
Question by:Saroj13
  • 2
3 Comments
 
LVL 52

Accepted Solution

by:
Carl Tawn earned 500 total points
ID: 35016614
You may find it's easier to implement that as a trigger on the database table rather than trying to do it through your app.
0
 

Author Comment

by:Saroj13
ID: 35019878
How to do that on the database table?
0
 
LVL 52

Expert Comment

by:Carl Tawn
ID: 35020132
Something like the following should do:
CREATE TRIGGER trgUpdateDate
ON YourTable
AFTER INSERT, UPDATE
AS
     UPDATE YourTable SET YourDateColumn = GETDATE()
           WHERE YourTable.YourKeyField = Inserted.YourKeyField

Open in new window

0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

861 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question