Sunday, April 5, 2009

DataBinder if else solution

Below is an example that will allow two different images to be displayed in an image control based on the DataBinder.Eval result.

<img src="<%# (Convert.ToInt32(DataBinder.Eval(Container.DataItem, "availabilityId")) == 1) ? "/images/available.gif" : "/images/scheduled.gif"%>" alt="schedule" id="scheduleImg" style="border:none"/>

No comments: