The requested page is not available for the requested platform. You are viewing the content for Default platform.

How to: Dynamically Change Images Displayed Within Data Cells

This example demonstrates how to dynamically change images displayed in the Change column's cells.

For a full example, see the Grid - Live Data demo.

The image below shows the result:


protected string GetIconImageUrl(GridViewDataItemTemplateContainer container) {
     Quote quote = (Quote)grid.GetRow(container.VisibleIndex);
     return String.Format("Images/{0}.gif", quote.Change >= 0 ? "Up" : "Down");

protected string GetPercentageText(GridViewDataItemTemplateContainer container) {
     Quote quote = (Quote)grid.GetRow(container.VisibleIndex);
     return HttpUtility.HtmlEncode(quote.Change.ToString("P"));