This is a migrated thread and some comments may be shown as answers.

[Solved] grid update action not throwing exception

0 Answers 64 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Hetal
Top achievements
Rank 1
Hetal asked on 10 Aug 2012, 12:26 PM
hello

I have telerik grid whose model is having PK which is user entered value. Update Action method is as follows.

public ActionResult Update_Magazine(string magtype, string lang, string region)
        {
             
            var repost = context.Magazines.FirstOrDefault(r => r.MAGAZINE_TYPE == magtype);
          
                if (repost != null)
                {
                    repost.MAGAZINE_LANG = lang;
                    repost.MAGAZINE_REGION = region;
                    repost.MODIFIED_BY = 1;
                    repost.MODIFIED_DATE = DateTime.Now;
                    TryUpdateModel(repost);
                    context.SaveChanges();
                }
                return View(new GridModel(context.Magazines));
             
        }

When record is updated, it shows PK field also as PK field value is user entered. So, if user edit record by entering already existing value in PK field, it is not throwing exception Dbupdateexception. Is there any problem in this?

How can I solve this?
Tags
General Discussions
Asked by
Hetal
Top achievements
Rank 1
Share this question
or