【ASPxGridView】 隐藏“新建”按钮 - hide new button

注意事项

ASPxGridView 的“新建”按钮是无法禁用的,只能隐藏。

 

实现方法

1. 激活 ASPxGridView 的“新建”按钮

 

2. 添加绑定事件 DataBound 处理代码

 

代码
ASPxGridView grid = sender as ASPxGridView;
if (0 == grid.VisibleRowCount)
{
    
for (int i = 0; i < grid.Columns.Count; i++)
    {
        
if (grid.Columns[i] is GridViewCommandColumn)
        {
            (grid.Columns[i] 
as GridViewCommandColumn).NewButton.Visible = false;
            
//注意,如果同时存在多个 CommandColumn,下面的 break 就不应该使用了。
            
//break;
        }
    }
}

 

 

 

 

posted on 2010-03-11 16:13  CsharpStyle  阅读(771)  评论(0编辑  收藏  举报