我想将 GridView 中的 Edit Delete Select 链接替换为图标。
我怎样才能以编程方式做到这一点?

最佳答案

对您来说可能会有所不同(取决于您拥有“编辑”、“删除”、“选择”按钮的位置)。我添加了一个网格 View ,并在第一列中有按钮。然后我在 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' />";

        }
    }

祝你好运!

关于asp.net - 自定义编辑删除选择 GridView 中的链接,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/9018649/

10-12 12:45