如何解除数据绑定控件的绑定 [英] how to unbind a data bound control
本文介绍了如何解除数据绑定控件的绑定的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何取消绑定数据控件...?
试图取消绑定诸如GridView的DataBound控件.我已经尝试了很多方法,但是最流行的方法是使用面板将其隐藏.
我想知道是否有任何方法可以将其解除绑定为null.
How to unbind a data control... ?
Trying to UNBind a DataBound Control like GridView. I have tried many things but most popular way is to hide it using panel.
I want to know if there is any way to unbind it to null.
GridView1.DataSource = null;
GridView1.DataBind();
我看不到这个工作... !!!任何想法... ????????
I don''t see this working ...!!! Any Ideas...????????
推荐答案
请关注以下内容,
correct-way-to-unbind-a-bindingsource-from- a-datagridview [ ^ ]
system.web.ui.webcontrols.basedataboundcontrol.datasource.aspx [ ^ ]
并且DataSource
是GridView
class
的属性,并且设置DataSource
的一部分的工作原理如下,
Please have a look followings,
correct-way-to-unbind-a-bindingsource-from-a-datagridview[^]
system.web.ui.webcontrols.basedataboundcontrol.datasource.aspx[^]
andDataSource
is a property ofGridView
class
and set part of theDataSource
is work something like below,
...
set
{
if (value != null)
{
//does some sort of validation on value;
}
this._dataSource = value;
...
}
因此null
value可以用来设置DataSource
property值.
希望对您有所帮助:)
So null
value is acceptable to set DataSource
property values.
Hope it helps :)
这始终有效...
This always works...
GridView1.DataSource = null;
GridView1.DataBind();
不知道为什么不是,但是它起作用了.总是...:))
Don''t know why it wasn''t but it works. always... :))
这篇关于如何解除数据绑定控件的绑定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文