Trouble updating the Datagrid currency(price) column to database

G

Guest

Have a datagrid that displays the price column in this format $12,400.00 from
a table.

Went to the Property Builder of the datagrid and selected the Price column
and changed the Data formatting expression to {0:c}

*********
Have the following code in the DataGrid1_UpdateCommand event handler


string key = DataGrid1.DataKeys[e.Item.ItemIndex].ToString();

//Price column
TextBox tb = (TextBox) e.Item.Cells[1].Controls[0];
string stPrice = tb.Text.SubString(1); //this is the decimal number without
the '$'
decimal dc = decimal.Parse(stPrice); //convert string number to decimal

DataSet1.CAR_DETAILRow r;

r = dataSet11.CAR_DETAIL.FindByCAR_ID(int.Parse(key));

r.PRICE=dc; //this line causes problems; in my table the datatype of Price is
//number and I keep getting the error "Input string was
not in a
//correct format."

oracleDataAdapter1.Update(dataSet11);
DataGrid1.DataBind();

DataGrid1.EditItemIndex = -1;
DataGrid1.DataBind();

*******************
Can anyone tell me what I'm doing wrong? I've also tried using
Convert.ToDecimal and still same error message.

Any suggestions would be appreciated.

I'm using c# and oracle9i table

Thanks

bebop
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,815
Latest member
treekmostly22

Latest Threads

Top