首页 > 解决方案 > 如何为选定的复选框值赋值

问题描述

我有一个包含位置的表格,我想分配一个数字。 每当我向它们输入值时,位置都有天数,它总是需要 7 并分配其他检查值。如何为特定复选框分配特定值?

    [HttpGet]
    public ActionResult SellerLocationEdit(string BayiID)
    {
        try
        {// _Bayi_Lokasyon is a model that contains seller locations 
            _Bayi_Lokasyon yeni = new _Bayi_Lokasyon();
            var getirTeslimat = Bayi_Teslimat_Bolgeleri.SqlSorguList("BayiID='"+BayiID+"'").ToList();
            var getirIl = Bayiler.SqlSorgu("BayiID='"+BayiID+"'");
            yeni.LokasyonListe = _Bayi_Teslimat_Bolgeleri.Checkbox(getirTeslimat,getirIl.IlID,BayiID).ToList();
            yeni.IlAdi = Il.SqlSorgu("ilID="+getirIl.IlID).ad_il;
            yeni.BayiAdi = getirIl.BayiAdi;
            yeni.IlID = getirIl.IlID;
            yeni.BayiTeslimatGunleri = getirIl.BayiTeslimatGunleri;
            yeni.BayiID = BayiID;
            return PartialView("BayiLokasyonDuzenle",yeni);
        }
        catch (Exception ex)
        {
            return Content(ex.Message);            
        }
    }


    [HttpPost]
    public ActionResult SellerLocationEdit(_Bayi_Lokasyon ekle)
    {// Bayi_Teslimat_Bolgeleri is a model for selected locations
        try
        {
            if(ekle.b!=null)
            {
                var silB = Bayi_Teslimat_Bolgeleri.SqlSorguList("BayiID='" + ekle.BayiID + "' and IlID=" + ekle.IlID + " and BayiTeslimatGunleri= " + ekle.BayiTeslimatGunleri ).ToList();
                Bayi_Teslimat_Bolgeleri.DeleteList(silB);
                //ilk once hepsini sil 
                foreach (var item in ekle.b)
                {
                    Bayi_Teslimat_Bolgeleri yeniB = new Bayi_Teslimat_Bolgeleri();
                    yeniB.IlID = ekle.IlID;
                    yeniB.BayiID = new Guid(ekle.BayiID);
                    yeniB.IlceID = item;
                    yeniB.BayiTeslimatGunleri = ekle.BayiTeslimatGunleri;
                    Bayi_Teslimat_Bolgeleri.Insert(yeniB);
                }

                return Json(new { success = true, text = "Ekleme işlemi tamamlandı ..." }, JsonRequestBehavior.AllowGet);
            }
            return Json(new { success = false, text ="Herhangi bir yer seçmediniz ..." }, JsonRequestBehavior.AllowGet);
        }
        catch (Exception ex)
        {
            return Json(new {success=false,text=ex.Message}, JsonRequestBehavior.AllowGet);     
        }
    }

标签: c#asp.net.netasp.net-mvc

解决方案


推荐阅读