PC Review

Thread Tools Rate Thread

DataGrid1_UpdateCommand (update price)

Posts: n/a
      23rd Jul 2005
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."


DataGrid1.EditItemIndex = -1;

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

Is there a better way of updating the changes of a datagrid to the database?

Any suggestions would be appreciated.

I'm using c# and oracle9i table



Reply With Quote

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Textbox Problem in DataGrid1_UpdateCommand Tom Grinnert Microsoft ASP .NET 0 15th Feb 2006 08:43 AM




All times are GMT +1. The time now is 02:07 AM.