Rowcommand do not fire after clicking button

前端 未结 2 754
后悔当初
后悔当初 2021-01-05 11:54

I have already find out the solution, i just want to post it so this may be useful for some people

This is the button that use command



        
2条回答
  •  耶瑟儿~
    2021-01-05 12:18

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

提交回复
热议问题