deed02392
deed02392

Reputation: 5022

Custom Edit Delete Select links in GridView

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

Upvotes: 4

Views: 1434

Answers (1)

Hanlet Escaño
Hanlet Escaño

Reputation: 17380

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!

Upvotes: 4

Related Questions