Rowcommand do not fire after clicking button

好久不见. 提交于 2019-11-30 19:44:42
Sarawut Positwinyu

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();
        }
    }
Amitesh Kaushik

You may have made EnableViewState="false" in grid.

If this is the case, Rowcommand Event will also not fire.

You have made EnableEventValidation="true" on page.

If this is the case, RowCommand Event Will Not Fire, Set This To false.

The solution is to set it to true.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!