Click here to Skip to main content
15,887,676 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I need to pass datatable value as json to angular js only if datatable contains data.So that I can alert the value of datatable in view.

What I have tried:

public DataTable GetChqStatus(decimal chqno)
{
    string sql = "select chqNo,status from tblchqNo where chqNo=@chqno and status='cancelled'";
    SqlParameter[] param = new SqlParameter[]
    {
        new SqlParameter("@chqno", chqno)
    };
    return DBO.GetTable(sql, param, CommandType.Text);
}




public ActionResult getchqStatus(decimal chqno)
       {
           DataTable dt = objemp.WithdrawalBs.GetChqStatus(chqno);
           if (dt.Rows.Count>0)
           {
           return Json(dt, JsonRequestBehavior.AllowGet);
           }


       }


$scope.ChqStatus = function(chqno)
   {
       crudServiceUser.GetChqStatus(chqno).then(function (result) {
           $scope.Cheque = result;

       })

   }
Posted
Comments
Ramesh Kumar Barik 22-Apr-17 2:22am    
Convert the datatable to an entity(YourClass object) list and expose that list to your angular js.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900