Open farzinmonsef opened 6 years ago
https://stackoverflow.com/questions/961612/how-to-make-update-panel-in-asp-net-mvc
https://weblogs.asp.net/dwahlin/emulating-the-updatepanel-in-asp-net-mvc-1-0-with-ajaxhelper
Code Project https://www.codeproject.com/Tips/871347/How-to-Use-Ajax-BeginForm
https://msdn.microsoft.com/en-us/library/dd381533%28v=vs.100%29.aspx
http://www.c-sharpcorner.com/article/asp-net-mvc-5-ajax-beginform-ajaxoptions-onsuccess-onfailure/
https://www.telerik.com/forums/how-to-reload-grid
$("#grid").data("kendoGrid").dataSource.read();
$("#grid").data("kendoGrid").dataSource.sync();
Multiple Ways To Bind Data To Kendo Grid In MVC
http://www.c-sharpcorner.com/article/multiple-ways-to-bind-data-to-kendo-grid-in-mvc/
@model Kendo_Ajax_BeginForm.Models.Company @using System.Web.Optimization @using Kendo.Mvc.UI @using Kendo.Mvc.Extensions @{ Layout = "~/Views/Shared/_Layout.cshtml"; }
@@
@@(Html.Kendo().Grid
using System; using System.Collections.Generic; using System.Data; using System.Data.Entity; using System.Linq; using System.Net; using System.Web; using System.Web.Mvc; using Kendo.Mvc.Extensions; using Kendo.Mvc.UI; using Kendo_Ajax_BeginForm;
namespace Kendo_Ajax_BeginForm.Controllers { public class CompanyController : Controller { private northwindEntities db = new northwindEntities();
public ActionResult Index()
{
return View();
}
public ActionResult BindGrid([DataSourceRequest]DataSourceRequest request)
{
try
{
decimal companyId = 0;
List<Models.Company> lst = new List<Models.Company>();
lst = GetGridData(Convert.ToInt32(companyId)).ToList();
DataSourceResult result = lst.ToDataSourceResult(request, p => new Models.Company
{
Id = p.Id,
Name = p.Name,
CompanyId = p.CompanyId,
});
return Json(result, JsonRequestBehavior.AllowGet);
}
catch (Exception ex)
{
var errorMsg = ex.Message.ToString();
return Json(errorMsg, JsonRequestBehavior.AllowGet);
}
}
public IEnumerable<Models.Company> GetGridData(decimal companyId)
{
List<Models.Company> objCmp = new List<Models.Company>();
List<Models.Company> listCompany = new List<Models.Company>();
objCmp.Add(new Models.Company() { Id = 1, Name = "Rupesh Kahane", CompanyId = 20 });
objCmp.Add(new Models.Company() { Id = 2, Name = "Vithal Wadje", CompanyId = 40 });
objCmp.Add(new Models.Company() { Id = 3, Name = "Jeetendra Gund", CompanyId = 30 });
objCmp.Add(new Models.Company() { Id = 4, Name = "Ashish Mane", CompanyId = 15 });
objCmp.Add(new Models.Company() { Id = 5, Name = "Rinku Kulkarni", CompanyId = 18 });
objCmp.Add(new Models.Company() { Id = 6, Name = "Priyanka Jain", CompanyId = 22 });
if (companyId > 0)
{
listCompany = objCmp.ToList().Where(a => a.Id==companyId).ToList();
return listCompany.AsEnumerable();
}
return objCmp.ToList().AsEnumerable();
}
public ActionResult BindGridOnSearch([DataSourceRequest]DataSourceRequest request, string companyId)
{
try
{
List<Models.Company> list = new List<Models.Company>();
list = GetGridData(Convert.ToInt32(companyId)).ToList();
DataSourceResult result = list.ToDataSourceResult(request, p => new Models.Company
{
Id = p.Id,
Name = p.Name,
CompanyId = p.CompanyId,
});
return Json(result, JsonRequestBehavior.AllowGet);
}
catch (Exception ex)
{
var errorMsg = ex.Message.ToString();
return Json(errorMsg, JsonRequestBehavior.AllowGet);
}
}
public ActionResult Categories_Read([DataSourceRequest]DataSourceRequest request)
{
IQueryable<Category> categories = db.Categories;
DataSourceResult result = categories.ToDataSourceResult(request, category => new {
CategoryID = category.CategoryID,
CategoryName = category.CategoryName,
Description = category.Description,
Picture = category.Picture,
});
return Json(result);
}
protected override void Dispose(bool disposing)
{
db.Dispose();
base.Dispose(disposing);
}
}
}
using System; using System.Collections.Generic; using System.Linq; using System.Web;
namespace Kendo_Ajax_BeginForm.Models { public class Company { public int Id { get; set; } public string Name { get; set; } public int? CompanyId { get; set; } } }
MVC UpdatePanel