高分求教DevExpress AspxGridView的编辑模版(EditForm)如何动态加载

newc_k 2009-03-11 02:59:19
最近在用AspxGridView发现一个问题,我想用一个用户控件(usercontrol)来做AspxGridView的编辑模版(EditForm),请大家先看一下代码大概有以下几段:
代码一:用构造一个模版接口,并给Grid的编辑模版

protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
this.QueryAllAndBind();
}
this.gvBaseInfoTypeList.Templates.EditForm = new BaseInfoTypeManagerTemplate();
}

代码二:模版类:


class BaseInfoTypeManagerTemplate : ITemplate
{

public void InstantiateIn(Control container)
{

GridViewEditFormTemplateContainer editFormTemplateContainer = container as GridViewEditFormTemplateContainer;

BaseInfoTypeManagerEditor _editForm = new UserControl().LoadControl("HR/Person/WebControl/BaseInfoTypeManagerEditor.ascx") as BaseInfoTypeManagerEditor;
_editForm.ID = "BaseInfoTypeManagerEditor";
editFormTemplateContainer.Controls.Add(_editForm);
//这里做了一些数据库的操作
if (editFormTemplateContainer.Grid.IsNewRowEditing)
{
_editForm.CurrntEntity = new BaseInfoTypeEntity();
}
else if (editFormTemplateContainer.Grid.IsEditing)
{
_editForm.CurrntEntity = new BaseInfoTypeBL().GetBaseInfoTypeByKey(editFormTemplateContainer.KeyValue.ToString());
_editForm.SetValue();
}

}
}

代码三:BaseInfoTypeManagerEditor.ascx这个用户控件页面上有一个Button,调用了AspxGridView的JS脚本,用于CallBack引发Grid的Updating事件

<dxe:ASPxButton ID="btnSave" runat="server" Text="保存" ValidationGroup="Save" Width="80px">
<Image Url="~/Images/HR/save.gif" />
<ClientSideEvents Click="function(s, e) {aspxGVUpdateEdit('gvBaseInfoTypeList');e.processOnServer=false;}" />
</dxe:ASPxButton>


现在问题来了,点击过代码三的Button后,页面去执行代码二,并且连续执行了2次,然后再去执行Grid的Updating,而代码二里面有数据库的操作,我不想让其多次执行。求教一下高手,如何有效的实现这个编辑模版,谢谢。

顺便说一下,做为编辑模版的用户控件上的界面控件是通过Text等属性赋值而非绑定字段的。
...全文
481 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
newc_k 2009-03-11
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 liujiayu10 的回复:]
帮助文件上有的吧
[/Quote]
Demo也看了Google也搜了,找不到与我这个类似的啊,能给个例子看看吗?
liujiayu10 2009-03-11
  • 打赏
  • 举报
回复
帮助文件上有的吧

110,499

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧