• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 629
  • Last Modified:

Get INT from DataTable C#

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
csharp_learner
Asked:
csharp_learner
  • 2
2 Solutions
 
Gautham JanardhanCommented:
numericUpDown1.Value  = Convert.ToInt32(ordt.Rows[0][7]);
0
 
angus_young_acdcCommented:
If you are using a decimal you would be better converting it to that type:

Convert.ToDecimal(ordt.Rows[0][7]);
0
 
angus_young_acdcCommented:
Actually you will also need .ToString() after the [7] if it is going to be initially an object.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now