0

hye friends.....
i need your help....i want to multiply 2 data.....the price from the database and the quantity from the textbox.....the total is in the textbox also.it should be like this price * quantity = total....so,i dont know how to do it....i've tried many ways but it stil error...by the way,i'm using asp.net and C# language...please help me....thanks in advance...

4
Contributors
7
Replies
8
Views
7 Years
Discussion Span
Last Post by kumar169
0

yes show us some code and we will be able to help you a bit more. How are you pulling the data from the database?

0

this is my coding....

double jumlah = Convert.ToDouble(GridView1.DataSourceID.Trim()) * Convert.ToDouble(TextBox3.Text.Trim());
TextBox7.Text = Convert.ToString(jumlah);

Edited by sakurayana: n/a

0

double jumlah = Convert.ToDouble(GridView1.DataSourceID.Trim()) * Convert.ToDouble(TextBox3.Text.Trim());
TextBox7.Text = Convert.ToString(jumlah);

0

You are trying to Multipy the datasourceID here which is going to be something like "SqlDataSource1" this will not work. Do you need to do this calculation for every row or just one? In this situation I am guessing you will want to convert a field in your gridview to a template field. Add a label or textbox with a custom ID. Then you can use the FindControl method to extract the information. In C I *think* it would be something like.


convert.Todouble((textbox)Gridview1.Rows[1].findcontrol("txtBox1").Text.Trim())*Convert.ToDouble(TextBox3.text.trim()

The thing is you just need to find your control inside of the girdview if you are using that to retrieve the information. If not you may want to look into retreiving a scalar value from the db and using that.

0

it stil error my fren....huhu i dont knw how to add a label or textbox with a custom ID....

0

hi,
first convert the datatype of both to int.use this convert.toint32(textbox1.text)
and the convert.toint32("database value"); and multyply both and store the result in int type varible and then convert the in to string and store it in the database
check this link.
your code look like

textbox1.text=convert.tostring(convert.toint32(textbox2.text)*convert.toint32(value1))

;

Edited by Ezzaral: Deleted link

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.