c# - Conditional image path using Eval -


i have 2 images progress.png , completed.png. depending on status in db table (in progress of complete), want display appropriate image. correct syntax iif() statement within asp.net? help.

pseudocode:  <asp:image imageurl='<%# iif(eval("status").equals("in progress") display - 'images/progress.png')  else if status equals "complete" display - 'images/complete.png' %>' /> 

i know not answer question regarding iif syntax, solve problem regarding displaying image.

i rather use this:

<asp:image imageurl='<%# getstatusimage(eval("status").tostring()) %>' /> 

and write following method in code-behind.

public string getstatusimage(string status) {      switch(status)          case "in progress":              return "images/progress.png";          break;          case "complete":              return "images/complete.png";          break;          case default:              return string.empty;          break;         } 

Comments

Popular posts from this blog

javascript - Enclosure Memory Copies -

php - Replacing tags in braces, even nested tags, with regex -