如何使用MVC3实体框架更新Sqlserver中的表中的记录 [英] How can i update a record in my table present in Sqlserver using MVC3 Entity Framework

查看:69
本文介绍了如何使用MVC3实体框架更新Sqlserver中的表中的记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hii to all,

我已经使用MVC3&成功地将数据从前端插入到SqlServer中的表中。实体框架,现在如何更新我的表?我可以使用我为插入记录创建的相同View更新吗?如果是,我如何在同一个视图中再使用一个按钮即更新,否则我需要再创建一个视图请帮助我使用代码。请指导通过使用一些对我更有帮助的LINQ查询我的上述要求..



我的表由5列组成(Empid,Ename,Designation,Salary,DeptNo )



谢谢

Ramu

Hii to all,
I have successfully inserted data in to a table present in a SqlServer from front end using MVC3 & Entity Framework,now how can i update my table? can i update with the same View which i have created for inserting the records?if yes how can i use one more button i.e for Update in the same View,or else i need to create one more view please help me with code.Please guide me the above requirement by using some LINQ Query which will be more helpfull to me..

My table Consist of 5 Columns (Empid, Ename, Designation, Salary, DeptNo)

Thanks
Ramu

推荐答案

简而言之,你的问题主题不相关:您(应该)通过模型更新控制器,而不是从视图中更新 - 但您可以从任何视图调用(理论上)任何控制器操作,并且还有ajax版本。

所以,正如我所看到的,你的知识存在一些差距。我建议你去这样的教程: http://www.asp。 net / mvc / tutorials / getting-started-with-ef-using-mvc [ ^ ]和一个关于Entity Framework数据操作的内容: http://www.dotnetcurry.com/ShowArticle.aspx?ID=619 [ ^ ]
To be short, your question topics are not related: you (should) update in the controller via the model, and not from the view - but you can call (theoretically) any controller action from any view, and there is the ajax version too.
So, as I see, you have some gaps in your knowledge. I suggest you go trough a tutorial like this: http://www.asp.net/mvc/tutorials/getting-started-with-ef-using-mvc[^] and one about Entity Framework data manipulation: http://www.dotnetcurry.com/ShowArticle.aspx?ID=619[^]


这篇关于如何使用MVC3实体框架更新Sqlserver中的表中的记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆