EVAL becomes failed, with IIF and Replace Function
I am bindingg the GridView via SqlDataSource. There is a binding column which may be return as NULL from DataSource or not. If it is not NULL then i ve to apply the Replace function. I have done this like
<asp:TemplateField HeaderText="Device Condition">
<ItemStyle HorizontalAlign="Left" VerticalAlign="Top" />
<HeaderStyle HorizontalAlign="Left" VerticalAlign="Top" />
<ItemTemplate>
<asp:TextBox ID="Device_Condition" runat="server"
Text='<%# IIF(Eval("Device_Condition") isnot System.DBNull.Value ,Replace(Eval("Device_Condition"), "IWFFWI", Chr(39)),Eval("Device_Condition")) %>'
BorderWidth="0px" ReadOnly ="true" CssClass="GrdTxtBoxStyle" ></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
IF value exists for Eval("Device_Condition") then its FINE but when it is NULL then "IIF" becomes fails and shows the following error
HERE : IWFFWI is going to be replace with single quoute chr(39)
Error Msg "Conversion from type 'DBNull' to type 'String' is not valid."
|