如何在MVC中插入 [英] How to insert in MVC

查看:87
本文介绍了如何在MVC中插入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好所有

i有一张桌子

和查看

当我从gird中选择任何记录去查看
$ b此视图中的$ b有texterea和2个按钮





i需要点击任意按钮2保存文本在现场记录中的记录表格



然后每个按钮更改表格中的字段值状态



什么我试过了:



public void UpdateStatus(int rtId,int rStatus)

{



var rupdate = _db.Requests.FirstOrDefault(x => x.Id == rId);

rtupdate.RStatusId = rStatus;

_db.Rs.Include();



//_db.Requests。

}

解决尝试这个:



  public   int  UdpateStatus( int  rtId, int  rStatus)
{
// 找到要更新的实体:
var rrupdate = _db.Requests.FirstOrDefault (x => x.Id == rtId);

// 更新值
rrupdate.RStatusId = rStatus ;

// 保存对记录的更改并返回受影响的行数。
return _db.SaveChanges();
}


Hello all
i have a table
and view
when i select any record from gird go to view
in this view have texterea and 2 buttons


i need when click on any button of 2 save text in field note in record of table

then every button change value of field in table name "status"

What I have tried:

public void UpdateStatus(int rtId, int rStatus)
{

var rupdate = _db.Requests.FirstOrDefault(x => x.Id == rId);
rtupdate.RStatusId = rStatus ;
_db.Rs.Include();

//_db.Requests.
}

解决方案

Try this:

public int UdpateStatus(int rtId, int rStatus)
{
    // Find the entity to update:
    var rrupdate = _db.Requests.FirstOrDefault(x=>x.Id == rtId);
    
    // Update the value
    rrupdate.RStatusId = rStatus;

    // Save changes to record and return number of affected rows.
    return _db.SaveChanges();
}


这篇关于如何在MVC中插入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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