当我尝试删除学生代表时,我收到此错误消息.. [英] When I try to delete student attendace I got this error message..

查看:87
本文介绍了当我尝试删除学生代表时,我收到此错误消息..的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

The parameters dictionary contains a null entry for parameter 'date' of non-nullable type 'System.DateTime' for method 'System.Web.Mvc.ActionResult DeleteStudentAttendance(System.DateTime, Int64, Int64, Int32)' in 'CMS.ClientPortal.Controllers.TransController'. An optional parameter must be a reference type, a nullable type, or be declared as an optional parameter.
Parameter name: parameters





我尝试过:





What I have tried:

public ActionResult DeleteStudentAttendance(DateTime date, Int64 classId, Int64 divId,int timing)
        {


            if (LoggedInUser != null && LoggedInUser.IsAuthenticated)
            {
                TransactionRepositories.DeleteStudentAttendanceForDate(date, LoggedInUser.BranchId, LoggedInUser.InstituteId, classId, divId,timing);

                TempData["actionresult"] = "Student Attendance Data For Class Deleted Successfully!!!";
                return Json("success");


            }
            return Json("error");

        }

推荐答案

您已经声明了一个将DateTime作为第一个参数的方法 - 和DateTime是一个值类型,这意味着它可以接受 null 值,这是你传递给它的值。



阅读错误消息,它解释了为了使它与现有数据一起工作所必须做的事情,但是我会查看调用该方法的代码并找出为什么你的代码认为它是好的想要一个 null 的日期......
You've declared a method which takes a DateTime as the first parameter - and DateTime is a Value Type, which means it can;t accept a null value, which is what you are passing to it.

Read the error message, and it explains what you have to do in order to make it work with your existing data, but I'd look at the code that calls the method and work out why your code thinks it's a good idea to have a null date at all ...


这篇关于当我尝试删除学生代表时,我收到此错误消息..的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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