Solved

Edit date in edit view asp.net mvc

Posted on 2011-03-01
3
482 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

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

A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

726 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