Skip to main content

iI am trying to pass data in action method 'CloseCase'CloseCase from cshtml page and want to pass an array of value at action side in controller.but I am getting an error.i I am new to asp.net mvc so I can't say whether my approach is correct. while

While passing value from ajax it is showing null value at 'CloseCase'CloseCase method. i I want to get `command.Parameters.Add(":ICD_CASE_ID", casedetail[0]);command.Parameters.Add(":ICD_CASE_ID", casedetail[0]); means casedetail[0]casedetail[0] value but while debugging i found value at method CloseCase null values. Any idea would be appreciated.

i am trying to pass data in action method 'CloseCase' from cshtml page and want to pass an array of value at action side in controller.but getting error.i am new to asp.net mvc whether my approach is correct. while passing value from ajax it is showing null value at 'CloseCase' method. i want to get `command.Parameters.Add(":ICD_CASE_ID", casedetail[0]); means casedetail[0] value but while debugging i found value at method CloseCase null values. Any idea would be appreciated.

I am trying to pass data in action method CloseCase from cshtml page and want to pass an array of value at action side in controller.but I am getting an error. I am new to asp.net mvc so I can't say whether my approach is correct.

While passing value from ajax it is showing null value at CloseCase method. I want to get command.Parameters.Add(":ICD_CASE_ID", casedetail[0]); means casedetail[0] value but while debugging i found value at method CloseCase null values. Any idea would be appreciated.

Source Link
Mohan
  • 248
  • 5
  • 18

Trying to pass json value from view to controller

i am trying to pass data in action method 'CloseCase' from cshtml page and want to pass an array of value at action side in controller.but getting error.i am new to asp.net mvc whether my approach is correct. while passing value from ajax it is showing null value at 'CloseCase' method. i want to get `command.Parameters.Add(":ICD_CASE_ID", casedetail[0]); means casedetail[0] value but while debugging i found value at method CloseCase null values. Any idea would be appreciated.

.cshtml

$(".btnrowvalue2").click(function () {
            //var casedetails = new Array();
            var tr = $(this).closest('tr');
            var casedetail={};
            var casedetails=[];
            casedetail["FirstCol"] = tr.find('input[name="Chkb"]').val();
            casedetail["SecondCol"] = tr.find('input[name="CaseId"]').val();
            casedetail["ThirdCol"] = tr.find('input[name="Desc"]').val();
            casedetail["FourthCol"] = tr.find('input[name="NBill"]').val();
            casedetail["FifthCol"] = tr.find('input[name="TAmnt"]').val();
            casedetail["SixthCol"] = tr.find('input[name="Stat"]').val();
            casedetail["SeventhCol"] = tr.find('input[name="Cron"]').val();
            casedetail["EightCol"] = tr.find('input[name="Clon"]').val();
            casedetails.push(casedetail);
            //alert('Type1 : ' + FirstCol + ' ' + SecondCol + ' ' + ThirdCol);
            $.ajax({
                type:"POST",
                url:"/Home/CloseCase",
                data:JSON.stringify(casedetails),
                contentType:"application/json; charset=utf-8",
            datatype:"json",
            success:function(r){
                alert(r + " record(s) inserted.");
            }
            });
        });

controller side

 public JsonResult CloseCase(List<Ipcell> casedetail)
        {            
          
            try
            {
                conn.Open();
                string qry = "UPDATE ASE_S SET ICD_STATUS='O',ICD_CLOSED_ON=:ICD_CLOSED_ON,ICD_CLOSED_BY=:ICD_CLOSED_BY WHERE ICD_CASE_ID =:ICD_CASE_ID";
                OracleCommand command = new OracleCommand(qry, conn);
                command.Parameters.Add(":ICD_CLOSED_ON", DateTime.Now);
                command.Parameters.Add(":ICD_CLOSED_BY", Session[CommonConstants.SESSION_USER_ID]);
                command.Parameters.Add(":ICD_CASE_ID", casedetail[0]);
               int insertedRecords=command.ExecuteNonQuery();
                return Json(insertedRecords);
            }
            catch (Exception ex)
            {

            }
            finally
            {
                conn.Close();
            }
            return null;
        }

model class

public class Ipcell
    {        
        public string CaseId { get; set; }
        public string Descripton { get; set; }
        public int NoOfBill { get; set; }
        public decimal TotalAmount { get; set; }
        public DateTime From { get; set; }
        public DateTime To { get; set; }
        public string Type { get; set; }
        public string Status { get; set; }
        public DateTime CreatedOn { get; set; }
        public DateTime ClosedOn { get; set; }
    }