Dynamically add CommandField of type Image to a grid or any container.
if (!IsPostBack)
{
CommandField ImageCommand = new CommandField();
ImageCommand.ButtonType = ButtonType.Image;
ImageCommand.DeleteImageUrl = "~/images/delete.gif";
ImageCommand.ShowCancelButton = false;
ImageCommand.ShowDeleteButton = true;
GridView1.Columns.Add(ImageCommand);
}
Then do the normal
protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
}
to delete or change as per your requirements.
Comments