?
Solved

Get INT from DataTable C#

Posted on 2009-04-14
3
Medium Priority
?
607 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 1200 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 200 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
Integration Management Part 2
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses
Course of the Month13 days, 10 hours left to enroll

750 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