Click here to Skip to main content
14,839,939 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Is it possible to multiply a number in my textbox by a value in the datagridview cell?

What I have tried:

So far I've got this code, not sure if I'm going along the correct lines...
e.Row.Cells[1].Value = (Convert.ToInt32(e.Row.Cells[1].Value) * Convert.ToInt32(OdrQuantityTxtBx.Text)).ToString(); //put the cell number as position in your gridview
Posted
Updated 10-Nov-20 20:26pm
v4

1 solution

Break the problem into multiple pieces.
Instead of trying to complete a single operation, define and assign variables for each portion.

So, part 1: get the cell value: e.Row.Cells[1].Value)
Before trying to convert in to an integer, check to see if it is numeric.
If it is, then convert it, otherwise reject it and don't try to build an output value

Part 2: get the text box value: OdrQuantityTxtBx.Text
As with part 1, check the value to see if it is a number

Assuming both values are numeric, produce the result: e * OdrQuantity

Convert that to a string and replace your cell value.
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900