Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Working with nulls in formview 1

Status
Not open for further replies.

jgd123456

Programmer
Nov 3, 2006
19
GB
Hi, i've been playing around with the formview today and have come into a few problems. My latest problem is handling nulls from the database. For example in my code i have a textbox:

<asp:TextBox ID="txtDescription" Text='<%# Bind("Description") %>' runat="server"></asp:TextBox>

The Description field in the database allows null values. When i try to edit a record that has a null value an exception is thrown.

I understand i can use the textbox on databinding event to convert the data to an empty string if the value is null but i have so many fields that allow nulls and this seems abit of a long winded way of doing it so i was wondering if there was a better way.

Appreciate if someone could help. Thanks
 
what is the exception that is thown.?

I would just create a stored procedure that returns your data in use the IsNull() funciton..

ex.
Select this, that , IsNull(description,'')
from sometable

Jim
 
Hi cheers, the problem i have is that i am binding it to a strongly typed dataset created in visual studio. I've discovered it's not just strings as well it's any sql datatype including dates. Any further suggestions?
 
Some sort of query has to fill the dataset. Just use IsNULL on each column you need to check, for a date I use

IsNull(DateColumn, '01/01/1900')

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top