asp.net – 自定义编辑删除选择GridView中的链接

我想将GridView中的编辑删除选择链接替换为图标.
我怎么能以编程方式执行此操作?

解决方法

它可能与您有所不同(取决于您具有编辑,删除,选择按钮的位置).我添加一个gridview,并在第一列中有Buttons.然后我在RowDataBound事件中添加了这个:

protected void GridView1_RowDataBound(object sender,GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DaTarow) {

            LinkButton lbedit = (LinkButton)e.Row.Cells[0].Controls[0];
            lbedit.Text = "<img src='https://www.google.com/logos/classicplus.png' />";
            //There is a literal in between
            LinkButton lbDelete = (LinkButton)e.Row.Cells[0].Controls[2];
            lbDelete.Text = "<img src='https://www.google.com/logos/classicplus.png' />";
            //There is a literal in between
            LinkButton lbSelect = (LinkButton)e.Row.Cells[0].Controls[4];
            lbSelect.Text = "<img src='https://www.google.com/logos/classicplus.png' />";

        }
    }

祝好运!

相关文章

### 创建一个gRPC服务项目(grpc服务端)和一个 webapi项目(...
一、SiganlR 使用的协议类型 1.websocket即时通讯协议 2.Ser...
.Net 6 WebApi 项目 在Linux系统上 打包成Docker镜像,发布为...
一、 PD简介PowerDesigner 是一个集所有现代建模技术于一身的...
一、存储过程 存储过程就像数据库中运行的方法(函数) 优点:...
一、Ueditor的下载 1、百度编辑器下载地址:http://ueditor....