草庐IT

data-win-bind

全部标签

c# - 在绑定(bind)到数据源的组合框上设置 SelectedItem

List_customers=getCustomers().ToList();BindingSourcebsCustomers=newBindingSource();bsCustomers.DataSource=_customers;comboBox.DataSource=bsCustomers.DataSource;comboBox.DisplayMember="name";comboBox.ValueMember="id";现在如何将组合框的项目设置为列表中第一个以外的项目?尝试过comboBox.SelectedItem=someCustomer;...还有很多其他的东西,但到目

c# - ProtoBuf-Net 和 Compact Framework 出现 "Invalid field in source data: 0"错误

有人知道使用ProtoBuf-Net在紧凑框架和完整.Net框架之间进行序列化/反序列化时有任何问题吗?我有一个名为LogData的类,我正在compactframework3.5下序列化,传输到服务器(运行.Netframework4.0),然后反序列化。有时它有效,有时它会抛出上述错误,我还没有将其缩小到任何特定原因。我用不同的值做了很多测试,但似乎无法找到错误发生时的任何韵律或原因。我在下面包括我的类(class)(减去各种构造函数)。我已多次查看两侧的字节缓冲区,但尚未发现通过线路从一侧发送到另一侧的数据存在差异。[ProtoContract]publicclassLogDat

c# - WPF:将列表绑定(bind)到列表框

我有一个类:publicclassA:INotifyPropertyChanged{publicListbList{get;set;}publicvoidAddB(Bb){bList.Add(b);NotifyPropertyChanged("bList");}publiceventPropertyChangedEventHandlerPropertyChanged;privatevoidNotifyPropertyChanged(stringinfo){if(PropertyChanged!=null){PropertyChanged(this,newPropertyChangedE

c# - 如何获取行数据绑定(bind)事件中单元格的值?以及如何检查单元格是否为空?

我正在使用sqldatasource和GridView。我想在RowDataBound事件中从GridView获取单元格的值?,因为我不能使用e.RowIndex。如果单元格为空,如何检查更新事件?我使用了if!=null,但它没有用,所以我需要检查它是否为空。谢谢 最佳答案 在RowdataBound事件中,您可以使用以下代码从gridview中获取单元格的值:[1]//从特定行获取用户名stringservicename=Convert.ToString(DataBinder.Eval(e.Row.DataItem,"Name"

c# - 什么是 Microsoft.Practices.EnterpriseLibrary.Data

我想知道什么Microsoft.Practices.EnterpriseLibrary.Data.dll是以及我们使用此程序集的原因。这个dll有什么好处?我想在3层架构上创建一个项目,并且很好奇执行sql查询的最佳方式是什么。我应该使用这个dll还是简单地使用SqlCommand和DataAdapter.目前我正在以这种方式工作:(DAL文件中的代码:)publicvoidInsert(longid){connection.Open();SqlCommanddCmd=newSqlCommand("test_procedure",connection);dCmd.CommandType

c# - 将枚举属性数据绑定(bind)到网格并显示描述

这是与HowtobindacustomEnumdescriptiontoaDataGrid类似的问题,但就我而言,我有多个属性。publicenumExpectationResult{[Description("-")]NoExpectation,[Description("Passed")]Pass,[Description("FAILED")]Fail}publicclassTestResult{publicstringTestDescription{get;set;}publicExpectationResultRequiredExpectationResult{get;set;

c# - WPF 从子 ItemsControl 数据模板内部绑定(bind)到父 ItemsControl

我需要能够从子ItemsControll数据模板内部绑定(bind)到父ItemsControl的属性:假设MyParentCollection(外部集合)属于以下类型:publicclassMyObject{publicStringValue{get;set;}publicListMySubCollection{get;set;}并且假设上述类中的MyChildObject属于以下类型:publicclassMyChildObject{publicStringName{get;set;}}如何从内部数据模板内部绑定(bind)到MyParentCollection.Value?我不能

c# - ASP.NET MVC 模型与 ListBoxFor 和 DropDownListFor 助手的绑定(bind)

我有以下模型:[Required(ErrorMessage="ServerNameRequired")][StringLength(15,ErrorMessage="ServerNameCannotExceed15Characters")]publicstringservername{get;set;}[Required(ErrorMessage="ServerOSTypeRequired")]publicstringos{get;set;}publicstring[]applications;我使用以下代码将文本框绑定(bind)到服务器名,效果很好:@Html.TextBoxFor

c# - .NET 模型绑定(bind)器

我试图在我的ASP.NETMVC4项目中创建自定义模型绑定(bind)器。但是我被IModelBinderiterfaces困住了。VS可以找到三个IModelBinder接口(interface)。在以下命名空间中。usingSystem.Web.Http.ModelBinding;usingSystem.Web.Mvc;usingSystem.Web.ModelBinding;boolBindModel(HttpActionContextactionContext,ModelBindingContextbindingContext)objectBindModel(Controlle

c# - WPF 数据网格 : DataGridComboxBox ItemsSource Binding to a Collection of Collections

情况:我在XAML中创建了一个DataGrid,并且ItemsSource绑定(bind)到包含属性的特定类的ObservableCollection。然后在C#中,我创建了一个DataGridTextColumn和一个DataGridComboBoxColumn,并将它们绑定(bind)到ObservableCollection中对象的属性。我可以将DataGridComboBoxColumn绑定(bind)到一个简单的Collection,但我想要做的是将它绑定(bind)到一个字符串集合的集合,这样对于每一行,DataGrid中的ComboBox都有一个不同的字符串集合。我没有这