如何禁用编辑? [英] How to disable Edit?

查看:117
本文介绍了如何禁用编辑?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在gridview中禁用单行的AutoGenerateEditButton?

How to disable AutoGenerateEditButtonfor single row in gridview?

推荐答案

注意:不熟悉VB ..但你可以使用任何一个在线转换器用于转换VB中的示例代码。或者至少这会给你一些想法。



你可以为此目的使用Gridview的 onRowDataBound 事件。 br />


从此方法中的特定行获取编辑按钮,因为在遍历此事件后每行都有界限。并且只是禁用它。



我希望这会给你一些想法。



NOTE: not familiar with VB.. but you can use any of the online converter's to convert the example code in VB. or at least this will give you some idea.

You can use Gridview's onRowDataBound event for this purpose.

Get the Editbutton from specific row in this method as each row is bounded after traversing this event. and just disable this.

I hope this will give you some idea.

protected void YourGridview_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
    LinkButton lb = (LinkButton)(e.Row.Cells[0].Controls[0]); // if edit button is at index 0 i.e cell zero. or change it as per your req.

     string value = e.Row.Cells[2].Text; // if U wana disable it on some cell's specific value.
    if(value == "What you want")
        {
            lb.Visible = false;
        }

    }

}







希望这会有所帮助。 :)




Hope this will help. :)


你可以在gridview的行数据绑定上执行此操作
You can do this on row databound of gridview


这篇关于如何禁用编辑?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆