现象:在vs2008页面设计视图下,如果smartgridview包在updatepanel中,则会出现控件错误,如出现“找到多个具有相同ID....”,同时,在设计视图修改的任何内容,在源试图都无法同步,该现象不会出现在vs2005.
解决方案:
1、修改smartgridview控件源码,修改方法OnInit,增加“base.DesignMode”判断。
protected override void OnInit(EventArgs e)
{
if (!base.DesignMode)
{
this.PreRender += new EventHandler(ZoomGridView_PreRender);
// 将需要扩展的功能对象添加到功能扩展列表里
if (!String.IsNullOrEmpty(this._mouseOverCssClass))
this._efs.Add(new MouseOverCssClassFunction());
if (!String.IsNullOrEmpty(this.BoundRowClickCommandName))
this._efs.Add(new RowClickFunction());
if (!String.IsNullOrEmpty(this.BoundRowDoubleClickCommandName))
this._efs.Add(new RowDoubleClickFunction());
// 遍历需要实现的功能扩展,并实现它
foreach (ExtendFunction ef in this._efs)
{
ef.ZoomGridView = this;
ef.Complete();
}
ObjectDataSource ods = this.Parent.FindControl(this.DataSourceID) as ObjectDataSource;
if (ods != null)
{
ods.Selected += new ObjectDataSourceStatusEventHandler(ods_Selected);
}
}
base.OnInit(e);
}