TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
shuchi
NA
10
0
how to capture null value(if present) from database
Dec 4 2006 10:32 AM
I am using C#.NET, Visual Web Develpoper, SQL Server 2000.
In my WebForm, I am trying to get the value from database using following code : Where OSP_OrderNum is the column name in database.
// Get the value of the OSP_OrderNum field.
ordernum = (string)DataBinder.Eval(e.Item.DataItem, "OSP_OrderNum");
Here I am trying to insert the value of OSP_OrderNum into a dropdownlist of a DataGrid. Now what I would like to do is
if (ordernum == " ")
{
insert Text : "**Select Order**" into DDL
}
else
{
insert : "**Select 'ordernum**' order"
}
When I am using this loop my code breaks on the 1st line itself where I have declared ordernum. It is not able to capture null value from the database and giving me error: Unable to cast object of type 'System.DBNull' to type 'System.String'
How do I Solve this ?
Please Help!!!!
Reply
Answers (
2
)
compile and integrate modules
Question about click events