Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Professional
ASP.NET 2.0 Professional If you are an experienced ASP.NET programmer, this is the forum for your 2.0 questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old July 6th, 2006, 06:53 AM
Authorized User
Join Date: Jun 2006
Posts: 28
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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" />
<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>

 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."

Similar Threads
Thread Thread Starter Forum Replies Last Post
iif function rohit_sant SQL Server 2000 11 December 24th, 2009 04:04 AM
help with IIf function rashi Access VBA 3 February 15th, 2008 10:07 AM
IIf Function - Multiple conditions carrie09 Access 2 June 13th, 2007 10:27 AM
Is there an IIF Function in SQL Server? treadmill Classic ASP Professional 4 January 17th, 2005 06:57 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.