Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.0 and 1.1 Basics
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics 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
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old April 28th, 2007, 01:10 AM
Authorized User
 
Join Date: Apr 2007
Location: delhi, delhi, India.
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to show text in datalist while value in NULL

hello guys,
pls solve my problem
my problem is that
i m retreive data from table but in some column the value is store NULL. i want that insist of NULL it wl display some text in datalist while data retreive from databse

Eg.
employee //table name

Date //column name

14/6/82
NULL
15/6/82

i want display it in this format

employee //table name

Date //column name

14/6/82
Date Not Filled
15/6/82

is it possible if yes then send me solution of this problem with the help of example.
thanks
  #2 (permalink)  
Old April 30th, 2007, 02:04 AM
Friend of Wrox
Points: 1,935, Level: 17
Points: 1,935, Level: 17 Points: 1,935, Level: 17 Points: 1,935, Level: 17
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2004
Location: United Kingdom
Posts: 550
Thanks: 0
Thanked 1 Time in 1 Post
Default

Depends how you are filling your datalist, one way could be checking for null from database itself using the ISNULL function, another way could be checking for null while binding, something like below:

<asp:Label Runat="server" ID="lblTest" text='<%#DataBinder.Eval(Container.DataItem,"no")= = DBNull.Value.ToString() ? "Date not filled" : DataBinder.Eval(Container.DataItem,"no")%>'>

There could be lot other ways too....

Regards
Mike

Fortune favours the brave, so don't regret on missed oppurtunities.
  #3 (permalink)  
Old May 1st, 2007, 12:59 AM
Authorized User
 
Join Date: Apr 2007
Location: delhi, delhi, India.
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default

helo sir,
 this is not working
it is giving error:

 BC30201: Expression expected

i m using ur solution in datalist like this:

<%# DataBinder.Eval(Container.DataItem,"promotiondue") == DBNull.Value.ToString() ? "Date not filled" : DataBinder.Eval(Container.DataItem,"promotiondue") %>

but they r not executing
can u send the sloution


Quote:
quote:Originally posted by mike_remember
 Depends how you are filling your datalist, one way could be checking for null from database itself using the ISNULL function, another way could be checking for null while binding, something like below:

<asp:Label Runat="server" ID="lblTest" text='<%#DataBinder.Eval(Container.DataItem,"no")= = DBNull.Value.ToString() ? "Date not filled" : DataBinder.Eval(Container.DataItem,"no")%>'>

There could be lot other ways too....

Regards
Mike

Fortune favours the brave, so don't regret on missed oppurtunities.
  #4 (permalink)  
Old May 1st, 2007, 06:36 AM
Wrox Author
Points: 13,255, Level: 49
Points: 13,255, Level: 49 Points: 13,255, Level: 49 Points: 13,255, Level: 49
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2005
Location: Ohio, USA
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

Personally, I do this in my SQL statements so I do not have to deal with NULL values in code.

SELECT ISNULL([column], 'No Data') as [column] FROM [table]

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
================================================== =========
Technical Editor for: Professional Search Engine Optimization with ASP.NET
http://www.wiley.com/WileyCDA/WileyT...470131470.html
================================================== =========
Why can't Programmers, program??
http://www.codinghorror.com/blog/archives/000781.html
================================================== =========
  #5 (permalink)  
Old September 1st, 2007, 06:28 PM
Registered User
 
Join Date: Sep 2007
Location: Detroit, MI, USA.
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

hey dparsons: great, great great aproach... you've just solved my misery... ;)

==============================================

...no such things as a day at the beach..
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
use datalist via xml to show picture in output zuz29 ASP.NET 2.0 Basics 0 May 27th, 2006 06:51 PM
How to show thumbnail in the GridView/DataList walgr2k ASP.NET 2.0 Basics 1 May 20th, 2006 10:17 AM
Text wrap in Datalist helix24 ASP.NET 2.0 Basics 0 May 12th, 2006 07:45 PM
Show item in datalist control keyvanjan ASP.NET 1.0 and 1.1 Professional 0 January 14th, 2006 03:44 PM
Show table in DataList miguel.ossa ASP.NET 1.0 and 1.1 Basics 1 February 26th, 2004 10:29 AM



All times are GMT -4. The time now is 08:37 PM.


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