简体   繁体   中英

I want to make datagrid readonly in behnd code, but do not see the option

I have a datagrid "AWGrid" which has EditCommandColumn and delete Templatecolumn.

When page loads I am checking for user privileges, if user does not have proper roles, it should just be able to view the content and edit and delete buttons should be disabled. Currently I am disabling those buttons on every event when they are clicked.

if (!wrp.PageAuthenticationForUser(currPage))
 {
    e.Item.Cells[0].Enabled = false;
     return;
 }

I want to disable those button on page load itself. Something like this

if (!wrp.PageAuthenticationForUser(currPage))
            {
                txtLbl.Text = "You are Not Authorized to do perform operation setup.";
                //AWGrid.ReadOny = true;
            }

But this does not seem to work. Is there a simple way to achieve this.

Thanks in advance.

将禁用按钮编码置于gridview rowdatabound事件中。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM