【问题标题】:Can't add entry to repository无法向存储库添加条目
【发布时间】:2012-05-21 11:13:02
【问题描述】:

我有一个 db 和 ET DBModel。我使用 PostgreSQL。

当我尝试将条目添加到我的网格时,没有任何反应。但删除和编辑工作正常。 我该怎么办?

谢谢。

这是控制器代码

 public ActionResult GetFormForAddOrEdit(string id)
    {
        if (string.IsNullOrEmpty(id))
        {
            return PartialView(new TypeDictModel());
        }
        else
        {
            TypeDict td = typeDictRepo.GetById(id);
            TypeDictModel tdt = new TypeDictModel() { Oid = td.Oid, FormOfProduction = td.FormOfProduction };
            return PartialView(tdt);
        }
    }


    public virtual string SaveTypeDictEntry(TypeDictModel tdm)
    {
        string newTDE = typeDictRepo.Save(tdm.Oid, tdm.FormOfProduction);
        return newTDE;
    }


    public virtual void DeleteEntry(string id)
    {
        typeDictRepo.Delete(id);
    }

这是视图

    function CloseTypeDictModal() {
    $('#EditTypeDictModal_Close').click();
}

function SaveNewEntry() {
    $.ajax({
        url: '@Url.Action("SaveTypeDictEntry", "TypeDict")',
        async: true,
        dataType: "html",
        type: 'POST',
        data: $('#TypeDictForm').serialize(),
        success: function (data) {

            CloseTypeDictModal();
            $('#newTypeDictGrid').jqGrid().trigger("reloadGrid");
        }
    });
} 

【问题讨论】:

  • 您的 Save 方法在存储库中做了什么?你是否使用断点来查看会发生什么?
  • 你能定义无效吗?预期结果是什么,实际结果是什么?

标签: c# jquery asp.net-mvc-3 jquery-ui postgresql


【解决方案1】:

修复了我的存储库。错过了这一行 Context.SaveChanges(); ^^

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-08-20
    • 2012-09-23
    • 2020-06-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-06-06
    • 2019-07-31
    相关资源
    最近更新 更多