Riya Singh

Riya Singh

  • NA
  • 88
  • 4.8k

data binding issue using ASAX..

Aug 9 2018 7:02 AM
using asax i bind data but in view it's showing error interenl server error 500 in console error.......while i return partialview  ... 
 
 
<script type="text/javascript">
function bindListdata() {
debugger
var mydate1 = $('#date1').val();
var mydate2 = $('#date2').val();
if (mydate1 != "" && mydate2 != "")
{
var productid = $('#ProductId').val();
if (productid == 0) {
productid = "All";
}
}
$.ajax({
url: "/bindpurchasereport",
type:"POST",
data: { productid: productid,mydate1: mydate1, mydate2: mydate2 },
success: function (data) {
$("#BindPurchaseRecord").html(data);
// $("#BindRecord").show();
},
});
}
</script>
 
 
 
public ActionResult bindpurchasereport(string productid, string dealerid, DateTime? mydate1, DateTime? mydate2)
{
var model = new CartSummary1();
ViewBag.FromDate = "From Date : " + mydate1.Value.ToShortDateString() + "";
ViewBag.ToDate = "To Date :" + mydate2.Value.ToShortDateString() + "";
var DistributorId = "";
if (Session["userid"] != null)
{
DistributorId = Session["userid"].ToString();
}
ViewBag.Name = Session["username"];
var DistributorName = Session["username"].ToString();
int IntProductId = 0;
if (productid != "All")
{
IntProductId = Convert.ToInt32(productid);
}
if (productid == "All")
{
List<Invoice1> proli = new List<Invoice1>();
model.GetInvoiceData = (from c in db.invoice.ToList()
where c.DistributorId == "Admin"
&& ( c.DistributorName == DistributorName)
&& (c.saledate >= mydate1 && c.saledate <= mydate2)
select new Invoice1
{
id = c.id,
saledate = c.saledate,
saleno = c.saleno,
AdminSaleno = c.AdminSaleno,
customerName = c.customerName,
DistributorName = c.DistributorName,
dispercent = c.dispercent,
paymentmode = c.paymentmode,
dealername = GetDealerName(c.dealerid),
NetAmount = c.NetAmount,
TaxAmount = c.TaxAmount,
}).ToList();
model.GetCartData = (from p in db.cartsummary.ToList()
where p.DistributorId == "Admin"
&& (p.DistributorName == DistributorName)
&& (p.saledate >= mydate1 && p.saledate <= mydate2)
select new CartSummary1
{
id = p.id,
productname = GetProductNameList(p.productid),
AdminSaleno = p.AdminSaleno,
saleno = p.saleno,
DistributorName = p.DistributorName,
customer = p.customer,
productid = p.productid,
Rate = p.Rate,
amount = p.amount,
Quantity = p.Quantity,
}).ToList();
return PartialView("bindpurchasereport", model);
}
 
 

Answers (1)