DataGrid1_UpdateCommand (update price)

Discussion in 'Microsoft Dot NET' started by Guest, Jul 23, 2005.

  1. Guest

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

    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

    Thanks

    bebop
     
    Guest, Jul 23, 2005
    #1
    1. Advertisements

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ron Allen

    Re: SQL Update Error

    Ron Allen, Jul 3, 2003, in forum: Microsoft Dot NET
    Replies:
    0
    Views:
    447
    Ron Allen
    Jul 3, 2003
  2. nospam
    Replies:
    13
    Views:
    330
  3. John Bailo

    Linux Price Watch Entries

    John Bailo, Oct 3, 2005, in forum: Microsoft Dot NET
    Replies:
    2
    Views:
    202
    Daniel O'Connell [C# MVP]
    Oct 4, 2005
  4. Steven Spits

    Convert Price.ToString("C2") to decimal again?

    Steven Spits, Jan 21, 2006, in forum: Microsoft Dot NET
    Replies:
    1
    Views:
    475
    Tim Wilson
    Jan 21, 2006
  5. caleprete60
    Replies:
    1
    Views:
    631
    PvdG42
    Nov 21, 2009
Loading...

Share This Page