Rowcommand点击按钮后不火 [英] Rowcommand do not fire after clicking button

查看:126
本文介绍了Rowcommand点击按钮后不火的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经找出解决办法,我只是想将它张贴所以这可能是对某些人有用

这是使用命令按钮

<dxwgv:ASPxGridView ID="gdvxUsers" runat="server" AutoGenerateColumns="False" Width="100%" KeyFieldName="UserName" onrowcommand="gdvxUsers_RowCommand">
        <Columns>
        <dxwgv:GridViewDataTextColumn Caption="Edit" VisibleIndex="0" Width="0px">
            <DataItemTemplate>
                <asp:ImageButton ID="imbEdit" runat="server"
                    CommandName = "Edit"
                    ImageUrl="~/images/icon/Edit-icon.png" ClientIDMode="Static" />
            </DataItemTemplate>
        </dxwgv:GridViewDataTextColumn>
</dxwgv:ASPxGridView>

    protected void gdvxUsers_RowCommand(object sender, DevExpress.Web.ASPxGridView.ASPxGridViewRowCommandEventArgs e)
    {
        switch (e.CommandArgs.CommandName)
        {
            case "Edit":



            break;
        }
    }

该行命令不火的按钮被点击时。

The Row Command is not fire when the button is clicked.

推荐答案

问题是,在的Page_Load 我用的DataBind()在我使用 rowcommand GridView的命令,看来以后的DataBind() rowcommand 将被取消。

The Problem is that on Page_Load I use Databind() command on the gridview I'm using rowcommand, it seems that after DataBind(), rowcommand is cancelled.

    protected void Page_Load(object sender, EventArgs e)
    {
            gdvxUsers.DataSource = GetAllUserAndRole();
            gdvxUsers.DataBind();            
    }

所以我只在第一次加载数据绑定解决这个问题。

So I fix this problem by binding data only on first load.

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            gdvxUsers.DataSource = GetAllUserAndRole();
            gdvxUsers.DataBind();
        }
    }

这篇关于Rowcommand点击按钮后不火的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆