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...

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?

this is my coding....

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

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

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.

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

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))

;

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.