c# - Gridview text changed event -
i calculating total of gridview price field values textbox in textboxchanged event of gridview. while cursor coming line: total +=convert.todecimal(mytextbox);
getting exception: input string not in correct format. here gridviewtext changed event code:
protected void txtprice_ontextchanged(object sender, system.eventargs e) { decimal total = 0.0m; foreach (gridviewrow gvr in grdtabrow.rows) { if (gvr.rowtype == datacontrolrowtype.datarow) { textbox tb = gvr.findcontrol("txtprice") textbox; string mytextbox = tb.tostring(); if (!mytextbox.equals("") && mytextbox != null) { total +=convert.todecimal(mytextbox); } } grdtabrow.footerrow.cells[2].text = total.tostring(); } }
try:
string mytextbox = tb.text.tostring(); total += convert.todecimal(mytextbox);
tostring() believe returns objects representation differs between objects , doesn't reprsent specific value of object. return full qualified name of object.the text member returns value of textbox. tostring() should optional
Comments
Post a Comment