Eval() display custom value if null

前端 未结 5 1410
猫巷女王i
猫巷女王i 2021-01-25 02:51

    \' />

<
5条回答
  •  有刺的猬
    2021-01-25 03:31

    by creating a public method You can complete this task very easily like

    public string testbind(object myvalue)
    {
      if (myvalue == null)
      {
         return "NA value";
      }
    
      return myValue.ToString();
    }
    

    Label Code:

    
    

    Or you may use

    <%#(String.IsNullOrEmpty(Eval("TypeOfPainting").ToString()) ? "NA" : Eval("TypeOfPainting"))%>
    

    You have to follow this type of scenarion.

    Hope it works.

提交回复
热议问题