Custom Edit Delete Select Links in GridView

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

+4
source share
1 answer

This may be different for you (depending on where you use the "Edit", "Delete", "Select" buttons). I added gridview and have buttons in the first column. Then I added this to 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

+4
source

Source: https://habr.com/ru/post/1393163/


All Articles