call function behind the image button in GridView

前端 未结 1 1866
死守一世寂寞
死守一世寂寞 2020-12-22 10:27

i am having two buttons in the gridview but they dont return anything event after using the \"CommandName\" in which i write the function name but it does not do anything.

1条回答
  •  粉色の甜心
    2020-12-22 11:08

    
                                        
                                            
                                                
                                                    
                                                
                                                                                            
                                            
                                            
                                            
                                            
                                            
                                                
                                                    
                                                
                                                                                            
                                        
                                        
    

    and here is the code behind:

    protected void gvProduct_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            GridViewRow Row = (GridViewRow)((Control)e.CommandSource).NamingContainer;
            int rowID = Convert.ToInt32(gvProduct.DataKeys[Row.RowIndex].Value);
    
            if (e.CommandName == "EditCommand")
            {
                EditFunction(rowID);
            }
            else
                if (e.CommandName == "DeleteCommand")
                {
                    DeleteFunction(rowID);
                }
        }
    

    0 讨论(0)
提交回复
热议问题