Control的Databindings问题

问题描述

现在有一个对象,有20个属性,需要增加或编辑,于是用到了DatabindingsMyobjectobj=newMyobjct();varbs=newBindingSource();bs.DataSource=bs;Textbox1.Databindings.Add("Text",bs,"A");....

现在,显示没有问题了。但是,我有一个需求,在某种情况下,obj需要被重新赋值,如obj=newobj;这个时候我使用如下方式更新:obj=newobj;bs.DataSource=obj;Textbox1.Databindings["Text"].ReadValue();//这里,如果不这样显示更新,则控件不能显示新的值。

问题是:我有几十个属性要更新,只能这样显示更新了吗?还有没其他办法?

解决方案

解决方案二:
bs.ResetBindings(true);

解决方案三:
谢谢,改天试试!!

时间: 2024-09-25 00:20:03

Control的Databindings问题的相关文章

解决 The Controls collection cannot be modified because the control contains code blocks

在.aspx或.ascx的如果包括<%= %>,并在.aspx, .ascs中使用了AjaxToolkit中的控件,那么很可能会引发"The Controls collection cannot be modified because the control contains code blocks" 异常, 解决办法如下 1. 将<%= 换为<%# 2. 在.asp或模板页中的Page_Load事件中添加如下代码 复制代码 代码如下: Page.Header.

Declarations and Access Control (2)

access Objective 2Declare classes, inner classes, methods, instance variables static, variables and automatic (method local) variables, making appropriate use of all permitted modifiers (such as public final static abstract and so forth). State the s

Flow control and exception Handling

2) Flow control and exception Handling Objective 1)Write code using if and switch statements and identify legal argument types for these statements. ·    Unreachable statements produce a compile-time error. while (false) { x = 3; } // won't compilefo

在自定义Server Control中捆绑JS文件 Step by Step

js|server 注:本文基于.NET 2.0 和 VS2005 我们在编写 Server Control 的时候难免要用到一些客户端脚本(javascript),如何把脚本和编译好的dll一起发布就成了一个问题.把一段一段的javascript block写在cs文件里是一件很"丑陋"的事情,javascript就应呆在*.js文件里.js文件怎样才能"打包"到dll里呢?查了很多文档,最后实践下来发现有很多细节是需要注意的.整理出来,免得大家走弯路.废话无多,

把Web Control导出为Excel或Word

excel|web|word /// <summary> /// 将Web控件导出 /// </summary> /// <param name="source">控件实例</param> /// <param name="type">类型:Excel或Word</param> public void ExpertControl(System.Web.UI.Control source, Doc

Declarations and Access Control (1)

access 1) Declarations and Access Control Objective 1Write code that declares, constructs and initializes arrays of any base type using any of the permitted forms, both for declaration and for initialization. 1.    Arrays are Java objects. (An object

使用Control Adapters优化Asp.net控件

asp.net|控件|优化 有些时候Asp.net 控件默认状态下生成的html代码,不能满足一些特定的需要.比如 我们想让用户做一些选择,可以很容易的用如下代码实现 <asp:CheckBoxList runat="server">   <asp:ListItem Text="One" />   <asp:ListItem Text="Two" />   <asp:ListItem Text="

Online CPU Console using a Web Control Library wit

WROXControlLibStep one is to set up a Web Control Library. Open Visual Studio .NET and choose a Web Control Library project. Add three new Custom Web Controls to the project named evenlog.cs, process.cs, and services.cs. Add System.ServiceProcess as

Coping with a New Beta - Data Server Control Templ

The .NET Framework Beta 2 has many changes that will break applications written in Beta 1. Among these changes is the templates used in Data Server Controls, such as the DataGrid and DataList. These are simply syntax changes in how templates are used