c# - 如何为选定的复选框值赋值
问题描述
我有一个包含位置的表格,我想分配一个数字。 每当我向它们输入值时,位置都有天数,它总是需要 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);
}
}
解决方案
推荐阅读
- r - 在 R 中的数据框中包含 OR 的 IF 语句
- asp.net - 具有认知身份验证的 ASP.NET Core 混合 Razor 页面/React SPA 应用程序
- ios - 区分 SpriteKit 中的光源
- java - 从我的 android 应用程序打开特定的 whatsapp 联系人
- java - 如何使 for 循环代码块运行得更快?
- python - 如何在 gspread 中预定义行数和列数
- android - 在 Android Dialog 片段 show() 方法的 TAG 参数中传递什么
- javascript - 如何渲染字符串或组件?
- python - 根据两个不同大小的数据框更新列并更新第一个数据框中的值。(python中vlookup的概念)
- javascript - 如何在不知道源代码的情况下为现有的 .exe 文件创建代码?