devxlogo

October 31, 2009

Add an Image Command Field to a GridView at Runtime in ASP.NET

It’s relatively easy to add an Image Command Field to a GridView programmatically. Here’s how: // in C#if (!Page.IsPostBack){ CommandField field = new CommandField(); field.ButtonType = ButtonType.Image; field.SelectImageUrl = “~/Images/MyPic.GIF”;