c# - Error while calculating percentage -
unable cast object of type 'system.web.ui.webcontrols.textbox' type 'system.iconvertible'.
i getting error while converting. have 2 text boxes in 1 have amount , in have percentage value should come in third text box.
public partial class caltxt : system.web.ui.page { double amt1; double exc; public void page_load(object sender, eventargs e) { } public void txtamt_textchanged(object sender, eventargs e) { amt1 = math.round(convert.todouble (txtamt)); //decimal percentagerate = convert.todecimal(this.txtamt.text); } protected void txtexc_textchanged(object sender, eventargs e) { double exc = math.round (convert.todouble(this.txtexc.text)); // decimal temp = (math.round(convert.todecimal(txtexc.text) / convert.todecimal(txtamt.text)*100)); // txttotalexc.text = temp.tostring(); } protected void txttotalexc_textchanged(object sender, eventargs e) { double totat = math.round (convert.todouble(exc) /100)* convert.todouble(amt1); //+ convert.toint32(this.txtexc.text); this.txttotalexc.text = totat.tostring(); } }
you should convert textbox.textproperty double instead of textbox
replace
amt1 = math.round(convert.todouble (txtamt)); with
amt1 = math.round(convert.todouble(txtamt.text));
Comments
Post a Comment