用ASPxButton替换ASPxGridViewTemplateReplacement

时间:2011-06-15 10:38:21

标签: aspxgridview

我有一个ASPxGridView,我在其中使用自定义EditForm,我想用dx替换默认的UpdateButton:ASPxGridViewTemplateReplacement用dx:ASPxButton代替

所以,这个

<dx:ASPxGridViewTemplateReplacement ID="UpdateButton" ReplacementType="EditFormUpdateButton" runat="server" />

应该是这样的

<dx:ASPxButton ID="UpdateButton" runat="server" Text="Spara" /> 

有任何建议吗?

谢谢

2 个答案:

答案 0 :(得分:2)

您需要停用AutoPostBack(将其设置为false),然后使用按钮上的client side Click event来验证更新表单&amp;触发更新,如下所示:

<dx:ASPxButton ID="UpdateButton" runat="server" Text="Spara" AutoPostBack= "false">
    <ClientSideEvents Click="OnUpdateClick"></ClientSideEvents>
</ASPxButton>

//JavaScript to hadle Update Button Click
function OnUpdateClick(s,e)
{
    if (ASPxClientEdit.ValidateGroup('mygroup'))
        grid.UpdateEdit();
}

答案 1 :(得分:0)

在开发快速支持网站上显示了更好的方法:

http://www.devexpress.com/Support/Center/p/S130677.aspx

<Templates>
<EditForm>
    <dx:ASPxGridViewTemplateReplacement ID="tr1" runat="server" ReplacementType="EditFormEditors" />
    <table style="float: right">
        <tr>
            <td>
                <dx:ASPxButton ID="b1" runat="server" UseSubmitBehavior="false" AutoPostBack="false"
                    Text="Update">
                    <ClientSideEvents Click="function(s){grid.UpdateEdit();}" />
                </dx:ASPxButton>
            </td>
            <td>
                <dx:ASPxButton ID="b2" runat="server" UseSubmitBehavior="false" AutoPostBack="false"
                    Text="Cancel">
                    <ClientSideEvents Click="function(s){grid.CancelEdit();}" />
                </dx:ASPxButton>
            </td>
        </tr>
    </table>
</EditForm>