Solved

Get INT from DataTable C#

Posted on 2009-04-14
3
572 Views
Last Modified: 2013-12-17
Hi I have a DataTable if INT and strings.

When i retrive the string from the DataTable "TextBox1.Text = datatable.Rows[0][2].ToString();"
I have no problem, but when i want to retrive a INT from the datatable in the same way to a numberupdownBox "numericUpDown1.Value = ordt.Rows[0][7];" the error "Cannot implicitly convert type object to decimal kept blocking.

How can I solve this?
0
Comment
Question by:csharp_learner
  • 2
3 Comments
 
LVL 29

Accepted Solution

by:
Gautham Janardhan earned 300 total points
Comment Utility
numericUpDown1.Value  = Convert.ToInt32(ordt.Rows[0][7]);
0
 
LVL 15

Assisted Solution

by:angus_young_acdc
angus_young_acdc earned 50 total points
Comment Utility
If you are using a decimal you would be better converting it to that type:

Convert.ToDecimal(ordt.Rows[0][7]);
0
 
LVL 15

Expert Comment

by:angus_young_acdc
Comment Utility
Actually you will also need .ToString() after the [7] if it is going to be initially an object.
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now