草庐IT

simple_bind_s

全部标签

c# - 未绑定(bind)模型项时如何添加 ModelState.AddModelError 消息

我是MVC4的新手。在这里,我添加了ModelState.AddModelError消息以在无法执行删除操作时显示。@Html.ValidationMessage("CustomError")@Html.ValidationSummary(true)在我的Controller中publicActionResultDelete(stringid,stringproductid){intrecords=DeleteItem(id,productid);if(records>0){ModelState.AddModelError("CustomError","Theitemisremoved

c# - 未绑定(bind)模型项时如何添加 ModelState.AddModelError 消息

我是MVC4的新手。在这里,我添加了ModelState.AddModelError消息以在无法执行删除操作时显示。@Html.ValidationMessage("CustomError")@Html.ValidationSummary(true)在我的Controller中publicActionResultDelete(stringid,stringproductid){intrecords=DeleteItem(id,productid);if(records>0){ModelState.AddModelError("CustomError","Theitemisremoved

c# - 如何简单地将其绑定(bind)到 ConverterParameter?

我有问题,我不知道如何解决这个简单的问题,我有很多这样的点,那么解决方案应该不复杂。我有带有设置和主XAML的主项目。我有绑定(bind)转换器和XAML文件的依赖项目:此XAML文件由主项目的主XAML文件加载。我必须将一个属性的值从Setting传递给ConverterParameter,这个参数可以在运行时改变,那么这必须是Binding,Binding在这种情况下,我只能为DependencyProperty做。我必须为此设置属性做DependencyProperty包装才能解决这个问题吗?当我尝试在ConverterParameter中设置Binding时,我将在运行时遇到此

c# - 如何简单地将其绑定(bind)到 ConverterParameter?

我有问题,我不知道如何解决这个简单的问题,我有很多这样的点,那么解决方案应该不复杂。我有带有设置和主XAML的主项目。我有绑定(bind)转换器和XAML文件的依赖项目:此XAML文件由主项目的主XAML文件加载。我必须将一个属性的值从Setting传递给ConverterParameter,这个参数可以在运行时改变,那么这必须是Binding,Binding在这种情况下,我只能为DependencyProperty做。我必须为此设置属性做DependencyProperty包装才能解决这个问题吗?当我尝试在ConverterParameter中设置Binding时,我将在运行时遇到此

c# - 输入 : How to bind an open generic with more than one type argument?

我正在使用Ninject2.2,我正在尝试为一个采用两个类型参数的开放泛型设置绑定(bind)。根据这个answer通过qes,绑定(bind)的正确语法IRepository至Repository这是:Bind(typeof(IRepository)).To(typeof(Repository));如果IRepository,上述语法将完美运行只接受一个类型参数,但如果需要更多类型参数则中断(给出Usingthegenerictype'Repository'requires2typearguments编译时错误。)如何绑定(bind)IRepository至Repository?谢谢

c# - 输入 : How to bind an open generic with more than one type argument?

我正在使用Ninject2.2,我正在尝试为一个采用两个类型参数的开放泛型设置绑定(bind)。根据这个answer通过qes,绑定(bind)的正确语法IRepository至Repository这是:Bind(typeof(IRepository)).To(typeof(Repository));如果IRepository,上述语法将完美运行只接受一个类型参数,但如果需要更多类型参数则中断(给出Usingthegenerictype'Repository'requires2typearguments编译时错误。)如何绑定(bind)IRepository至Repository?谢谢

c# - WPF 数据绑定(bind) : How to data bind an enum to combo box using XAML?

这个问题在这里已经有了答案:HowtobindanenumtoacomboboxcontrolinWPF?(21个答案)关闭6年前。我有一个类:publicclassAccountDetail{publicDetailScopeScope{get{returnscope;}set{scope=value;}}publicstringValue{get{returnthis.value;}set{this.value=value;}}privateDetailScopescope;privatestringvalue;publicAccountDetail(DetailScopescop

c# - WPF 数据绑定(bind) : How to data bind an enum to combo box using XAML?

这个问题在这里已经有了答案:HowtobindanenumtoacomboboxcontrolinWPF?(21个答案)关闭6年前。我有一个类:publicclassAccountDetail{publicDetailScopeScope{get{returnscope;}set{scope=value;}}publicstringValue{get{returnthis.value;}set{this.value=value;}}privateDetailScopescope;privatestringvalue;publicAccountDetail(DetailScopescop

c# - 如何绑定(bind) ComboBox 以便 displaymember 是源数据表的 2 个字段的 concat?

我想将一个ComboBox绑定(bind)到一个DataTable(我不能改变它的原始模式)cbo.DataSource=tbldata;cbo.DataTextField="Name";cbo.DataValueField="GUID";cbo.DataBind();我想要ComboBox显示tbldata.Name+tbldata.Surname。当然,在绑定(bind)之前将新名称+姓氏作为字段添加到tbldata是可能的,但我希望有一个更优雅的解决方案(伪代码)cbo.DataTextField="Name";cbo.DataTextField+="Surname";

c# - 如何绑定(bind) ComboBox 以便 displaymember 是源数据表的 2 个字段的 concat?

我想将一个ComboBox绑定(bind)到一个DataTable(我不能改变它的原始模式)cbo.DataSource=tbldata;cbo.DataTextField="Name";cbo.DataValueField="GUID";cbo.DataBind();我想要ComboBox显示tbldata.Name+tbldata.Surname。当然,在绑定(bind)之前将新名称+姓氏作为字段添加到tbldata是可能的,但我希望有一个更优雅的解决方案(伪代码)cbo.DataTextField="Name";cbo.DataTextField+="Surname";