型号:
public class Everything
{
public List<MUSTERILER> Musteriler { get; set; }
public List<KISALTMALAR> Kisaltmalar { get; set; }
public List<ILETISIMLER> Iletisimler { get; set; }
public List<TEKLIFLER> Teklifler { get; set; }
public List<SEHIRLER> Sehirler { get; set; }
public List<ILCELER> İlceler { get; set; }
}
我将所有表组合在一个类中:
public Everything Alltables()
{
return new Everything // All Tables Here From Database
{
Musteriler = context.MUSTERILER.ToList(),
Iletisimler = context.ILETISIMLER.ToList(),
Teklifler = context.TEKLIFLER.ToList(),
Kisaltmalar = context.KISALTMALAR.ToList(),
Sehirler = context.SEHIRLER.ToList(),
İlceler = context.ILCELER.ToList(),
};
}
查看:
using (Ajax.BeginForm("Index", new AjaxOptions { HttpMethod = "POST" }))
{
{
Html.DevExpress().DropDownEdit(
s =>
{
s.Name = "MusteriKaynagiDropdownEdit";
s.Text = Convert.ToString(Session["MusteriKaynagi"]);
s.Width = 250;
s.SetDropDownWindowTemplateContent(c =>
{
Html.DevExpress().ListBox(
listBoxSettings =>
{
listBoxSettings.Name = "KISALTMALAR_ACIKLAMA";
listBoxSettings.Properties.ValueField = "KISALTMALAR_ID";
listBoxSettings.Properties.TextField = "KISALTMALAR_ACIKLAMA";
listBoxSettings.Properties.ValueType = typeof(int);
listBoxSettings.Width = System.Web.UI.WebControls.Unit.Percentage(100);
listBoxSettings.Properties.ClientSideEvents.SelectedIndexChanged = "function(s, e)
{ document.forms[0].submit(); }";
})
.BindList(Model.Kisaltmalar.Where(y => y.KISALTMALAR_AYRAC == 4).ToList())
.Bind(Model.Kisaltmalar)
.Render();
});
}
).GetHtml();
}
}
控制器:
public ActionResult Index(KISALTMALAR KISALTMALAR_ACIKLAMA)
{
return View(AllTables);
}
如果ı选择要发送到我的actionresult的项目,ı得到此例外 没有为此对象定义无参数构造函数
添加什么,在哪里改变任何想法?
答案 0 :(得分:0)
以下是StackOverflow KB的第一个搜索结果:
ASP.NET MVC: No parameterless constructor defined for this object
为模型类型(“索引”方法的参数)强制使用虚拟“无参数构造函数”来解决此问题。