4

I want to replace the Edit Delete Select links in GridView to be icons.
How can I do this programatically?

Mxyk
  • 10,678
  • 16
  • 57
  • 76
deed02392
  • 4,799
  • 2
  • 31
  • 48

1 Answers1

4

It might be different for you (depending where you have the Edit, Delete, Select buttons). I added a gridview, and have the Buttons in the first Column. Then I added this in the RowDataBound event:

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' />";

        }
    }

Good luck!

Hanlet Escaño
  • 17,114
  • 8
  • 52
  • 75