我想用Bind值制作一些字符串。很容易,除了其中一个正在弄乱我。 _surveyID
=“0”
SurveyController:
public ActionResult Create([Bind(Include = "SurveyID,SurveyName,SenderID,ConsultantID,ResponderID,Question1,Question2,Question3,Question4,Question5,SurveyTime")] Survey survey)
{
if (ModelState.IsValid)
{
string _surveyID = survey.SurveyID.ToString();
string _surveyName = survey.SurveyName;
string _surveyTime = survey.SurveyTime.ToString();
//ANOTHER ATTEMPT, SAME RESULT
//string _surveyID = db.Surveys
//.FirstOrDefault(x => x.SurveyID == survey.SurveyID)
//.SurveyID;
}
SurveyID
to database = 1002
SurveyID
到_surveyID
=“0”
请注意,_surveyName
和_surveyTime
都正常运作。
survey
绑定值:http://i.imgur.com/khEDUns.png
当我尝试提取值时,为什么我的SurveyID设置为0?
编辑:投放到数据库时是否创建了ID值?我的代码在代码流程中是否太快了?
EDIT2:这是一个bump1