Hi all,
I have problem while update listview. 2 parameter: CreateDate and LastUpdate are miss when send by POST or GET.
Please let me know where is problem. Thank so much!
Model:
public partial class spGetCardPolicyByDiscountIDAndResID_Result
{
public short ConditionID { get; set; }
public string ConditionName { get; set; }
public string Note { get; set; }
public System.DateTime CreateDate { get; set; }
public long CreateBy { get; set; }
public System.DateTime LastUpdate { get; set; }
public long UpdateBy { get; set; }
public long RestaurantID { get; set; }
public int DiscountPolicyID { get; set; }
public byte CardLevelIID { get; set; }
public string CardLevelName { get; set; }
public string Description { get; set; }
}
Controller:
public ActionResult Update([DataSourceRequest] DataSourceRequest request, spGetCardPolicyByDiscountIDAndResID_Result card, string discountID, string restaurantID)
{
AccountSession accsession = (AccountSession)Session["UserTGNH"];
bool success = ResCardDataAccess.GetInstance().Update(card, discountID, restaurantID, accsession.AccountID);
if (success)
{
return Json(ModelState.ToDataSourceResult(), JsonRequestBehavior.AllowGet);
}
else return null;
}
View:
---Template
@model IEnumerable<TGNH.Models.spGetCardPolicyByDiscountIDAndResID_Result>
@{
string[] parameter = ViewBag.Parameter;
}
<div class="k-toolbar k-grid-toolbar">
<a class="k-button k-button-icontext k-add-button" href="#"><span class="k-icon k-add"></span>Add new record</a>
</div>
<script id="card-list-view-template" type="text/x-kendo-template">
<div class="product-view">
<dl>
<dt>Card Name</dt>
<dd>${CardLevelName}</dd>
<dt>Description</dt>
<dd>${Description}</dd>
<dt>Condition</dt>
<dd>${ConditionName}</dd>
<dt>Note</dt>
<dd>${Note}</dd>
</dl>
<div class="edit-buttons">
<a class="k-button k-button-icontext k-edit-button" href="\\#"><span class="k-icon k-edit"></span>Edit</a>
<a class="k-button k-button-icontext k-delete-button" href="\\#"><span class="k-icon k-delete"></span>Delete</a>
</div>
</div>
</script>
@(Html.Kendo().ListView<TGNH.Models.spGetCardPolicyByDiscountIDAndResID_Result>(Model)
.Name("cardlistView" + @parameter[0])
.TagName("div")
.ClientTemplateId("card-list-view-template")
.DataSource(dataSource => dataSource
.Model(model => model.Id("CardLevelIID"))
.PageSize(6)
.Create(create => create.Action("Create", "ResCard", new { discountID = @parameter[0], restaurantID = @parameter[1] }))
.Read(read => read.Action("GetCardPolicyByDiscountIDAndResID", "ResDiscountPolicy", new { discountID = @parameter[0], restaurantID = @parameter[1] }))
.Update(update => update.Action("Update", "ResCard", new { discountID = @parameter[0], restaurantID = @parameter[1] }).Type(HttpVerbs.Post))
.Destroy(destroy => destroy.Action("Editing_Destroy", "ListView"))
)
.Editable()
)
<script>
$(function () {
var listView = $("#cardlistView").data("kendoListView");
$(".k-add-button").click(function (e) {
listView.add();
e.preventDefault();
});
});
</script>
---EditorTemplate
@model TGNH.Models.spGetCardPolicyByDiscountIDAndResID_Result
<div class="product-view">
<dl>
<dt>Card Name</dt>
<dd>
@(Html.EditorFor(p=>p.CardLevelName))
<span data-for="ProductName" class="k-invalid-msg"></span>
</dd>
<dt>Description</dt>
<dd>
@(Html.EditorFor(p=>p.Description))
<span data-for="UnitPrice" class="k-invalid-msg"></span>
</dd>
<dt>Condition</dt>
<dd>
@(Html.EditorFor(p=>p.ConditionName))
<span data-for="UnitsInStock" class="k-invalid-msg"></span>
</dd>
<dt>Note</dt>
<dd>@(Html.EditorFor(p=>p.Note))</dd>
</dl>
<div class="edit-buttons">
<a class="k-button k-button-icontext k-update-button" href="\\#"><span class="k-icon k-update"></span>Save</a>
<a class="k-button k-button-icontext k-cancel-button" href="\\#"><span class="k-icon k-cancel"></span>Cancel</a>
</div>
</div>
I have problem while update listview. 2 parameter: CreateDate and LastUpdate are miss when send by POST or GET.
CardLevelIID | 1 |
CardLevelName | Member |
ConditionID | 1 |
ConditionName | Khi mua đặt từ 5 bàn trở lên |
CreateBy | 1 |
Description | Only Member |
DiscountPolicyID | 1 |
Note | Chú ý chỉ áp dụng cho những thành viên VIP |
RestaurantID | 4 |
UpdateBy | 2 |
Please let me know where is problem. Thank so much!
Model:
public partial class spGetCardPolicyByDiscountIDAndResID_Result
{
public short ConditionID { get; set; }
public string ConditionName { get; set; }
public string Note { get; set; }
public System.DateTime CreateDate { get; set; }
public long CreateBy { get; set; }
public System.DateTime LastUpdate { get; set; }
public long UpdateBy { get; set; }
public long RestaurantID { get; set; }
public int DiscountPolicyID { get; set; }
public byte CardLevelIID { get; set; }
public string CardLevelName { get; set; }
public string Description { get; set; }
}
Controller:
public ActionResult Update([DataSourceRequest] DataSourceRequest request, spGetCardPolicyByDiscountIDAndResID_Result card, string discountID, string restaurantID)
{
AccountSession accsession = (AccountSession)Session["UserTGNH"];
bool success = ResCardDataAccess.GetInstance().Update(card, discountID, restaurantID, accsession.AccountID);
if (success)
{
return Json(ModelState.ToDataSourceResult(), JsonRequestBehavior.AllowGet);
}
else return null;
}
View:
---Template
@model IEnumerable<TGNH.Models.spGetCardPolicyByDiscountIDAndResID_Result>
@{
string[] parameter = ViewBag.Parameter;
}
<div class="k-toolbar k-grid-toolbar">
<a class="k-button k-button-icontext k-add-button" href="#"><span class="k-icon k-add"></span>Add new record</a>
</div>
<script id="card-list-view-template" type="text/x-kendo-template">
<div class="product-view">
<dl>
<dt>Card Name</dt>
<dd>${CardLevelName}</dd>
<dt>Description</dt>
<dd>${Description}</dd>
<dt>Condition</dt>
<dd>${ConditionName}</dd>
<dt>Note</dt>
<dd>${Note}</dd>
</dl>
<div class="edit-buttons">
<a class="k-button k-button-icontext k-edit-button" href="\\#"><span class="k-icon k-edit"></span>Edit</a>
<a class="k-button k-button-icontext k-delete-button" href="\\#"><span class="k-icon k-delete"></span>Delete</a>
</div>
</div>
</script>
@(Html.Kendo().ListView<TGNH.Models.spGetCardPolicyByDiscountIDAndResID_Result>(Model)
.Name("cardlistView" + @parameter[0])
.TagName("div")
.ClientTemplateId("card-list-view-template")
.DataSource(dataSource => dataSource
.Model(model => model.Id("CardLevelIID"))
.PageSize(6)
.Create(create => create.Action("Create", "ResCard", new { discountID = @parameter[0], restaurantID = @parameter[1] }))
.Read(read => read.Action("GetCardPolicyByDiscountIDAndResID", "ResDiscountPolicy", new { discountID = @parameter[0], restaurantID = @parameter[1] }))
.Update(update => update.Action("Update", "ResCard", new { discountID = @parameter[0], restaurantID = @parameter[1] }).Type(HttpVerbs.Post))
.Destroy(destroy => destroy.Action("Editing_Destroy", "ListView"))
)
.Editable()
)
<script>
$(function () {
var listView = $("#cardlistView").data("kendoListView");
$(".k-add-button").click(function (e) {
listView.add();
e.preventDefault();
});
});
</script>
---EditorTemplate
@model TGNH.Models.spGetCardPolicyByDiscountIDAndResID_Result
<div class="product-view">
<dl>
<dt>Card Name</dt>
<dd>
@(Html.EditorFor(p=>p.CardLevelName))
<span data-for="ProductName" class="k-invalid-msg"></span>
</dd>
<dt>Description</dt>
<dd>
@(Html.EditorFor(p=>p.Description))
<span data-for="UnitPrice" class="k-invalid-msg"></span>
</dd>
<dt>Condition</dt>
<dd>
@(Html.EditorFor(p=>p.ConditionName))
<span data-for="UnitsInStock" class="k-invalid-msg"></span>
</dd>
<dt>Note</dt>
<dd>@(Html.EditorFor(p=>p.Note))</dd>
</dl>
<div class="edit-buttons">
<a class="k-button k-button-icontext k-update-button" href="\\#"><span class="k-icon k-update"></span>Save</a>
<a class="k-button k-button-icontext k-cancel-button" href="\\#"><span class="k-icon k-cancel"></span>Cancel</a>
</div>
</div>