> search data not being displayed after search using ajax in mvc..data binding also completed but display is not done
@* *@
@Html.DropDownList("MasterGenericID", null, "--- Select Therapeutic ---", new { @class = "select2-arrow" })
@Html.DropDownList("MasterTherapeuticID", null, "--- Select Therapeutic ---", new { @class = "select2-arrow" })
@Html.DropDownList("MasterSubTherapeuticID", null, "--- Select Therapeutic ---", new { @class = "select2-arrow" })
@Html.DropDownList("MasterFormulationID", null, "--- Select Therapeutic ---", new { @class = "select2-arrow" })
| BrandName | GenericName | TherapeuticName | PcompanyNAme | Formulation | MRP |
|---|---|---|---|---|---|
| @item.BrandName | @item.GenericName | @item.TherapeuticName | @item.PcompanyNAme | @item.Formulation | @item.MRP |
@section scripts{
$(document).ready(function () {
$("#btnsearch").click(function (e) {
e.preventDefault();
var TherapeuticID = $('#MasterTherapeuticID').val();
var SubTherapeuticID =$('#MasterSubTherapeuticID').val();
var FormulationID = $('#MasterFormulationID').val();
var Conurl = '@Url.Action("ProductMasterview", "ProductMaster")' + '?TherapeuticID=' + TherapeuticID + "&SubTherapeuticID=" + SubTherapeuticID + "&FormulationID=" + FormulationID;
$.ajax({
type: 'POST',
url: Conurl,
data: JSON.stringify(Conurl),
dataType: 'json',
success: function () {
alert("Search Completed!");
}
});
});
});
}
public ActionResult ProductMasterview(int? TherapeuticID, int? FormulationID, int? SubTherapeuticID, int? pageNumber)
{
if (TherapeuticID > 0 || FormulationID > 0 || SubTherapeuticID > 0)
{
//Generic_Bind();
Therapeutic_Bind();
SubTherapeutic_Bind();
Formulation_Bind();
Productmaster model = new Productmaster();
model.PageNumber = (pageNumber == null ? 1 : Convert.ToInt32(pageNumber));
model.PageSize = 25;
List products = dPMSP.GetAllProductsUsingGenericID(TherapeuticID);
if (products != null)
{
model.Products = products.OrderBy(x => x.ProductID)
.Skip(model.PageSize * (model.PageNumber - 1))
.Take(model.PageSize).ToList();
model.TotalCount = products.Count();
var page = (model.TotalCount / model.PageSize) - (model.TotalCount % model.PageSize == 0 ? 1 : 0);
model.PagerCount = page + 1;
}
var data = new { products = products, Model = model };
return View(model);
}
else
{
//Generic_Bind();
Therapeutic_Bind();
SubTherapeutic_Bind();
Formulation_Bind();
Productmaster model = new Productmaster();
model.PageNumber = (pageNumber == null ? 1 : Convert.ToInt32(pageNumber));
model.PageSize = 25;
List products = dPMSP.GetAllProducts();
if (products != null)
{
model.Products = products.OrderBy(x => x.ProductID)
.Skip(model.PageSize * (model.PageNumber - 1))
.Take(model.PageSize).ToList();
model.TotalCount = products.Count();
var page = (model.TotalCount / model.PageSize) - (model.TotalCount % model.PageSize == 0 ? 1 : 0);
model.PagerCount = page + 1;
}
var data = new { products = products, Model=model };
return View(model);
}
}
Replies
Know the answer? Post it — somebody with the same question will find it here.