Solved

Get INT from DataTable C#

Posted on 2009-04-14
3
573 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
ID: 24145155
numericUpDown1.Value  = Convert.ToInt32(ordt.Rows[0][7]);
0
 
LVL 15

Assisted Solution

by:angus_young_acdc
angus_young_acdc earned 50 total points
ID: 24146181
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
ID: 24146216
Actually you will also need .ToString() after the [7] if it is going to be initially an object.
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Run time Error 4 34
Exit the loop 4 34
Facial recognition to look through the whole database for a person 3 40
Close form "before" open 3 19
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
This is a video describing the growing solar energy use in Utah. This is a topic that greatly interests me and so I decided to produce a video about it.

914 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

21 Experts available now in Live!

Get 1:1 Help Now