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?

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

    ASP.Net CheckBoxList Batch Update

    Rick, Jul 8, 2003, in forum: Microsoft Dot NET
    Replies:
    0
    Views:
    823
  2. Software Development

    ANN: 'CodeSMART 2003 for VS .NET' Add-In, 3rd Update

    Software Development, Jul 10, 2003, in forum: Microsoft Dot NET
    Replies:
    0
    Views:
    502
    Software Development
    Jul 10, 2003
  3. Steve Roberts

    Properties bound textboxes do not update.

    Steve Roberts, Jul 10, 2003, in forum: Microsoft Dot NET
    Replies:
    0
    Views:
    466
    Steve Roberts
    Jul 10, 2003
  4. mstjean
    Replies:
    1
    Views:
    682
    Phil Wilson
    Jul 15, 2003
  5. nospam
    Replies:
    13
    Views:
    374
  6. John Bailo

    Linux Price Watch Entries

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

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

    Steven Spits, Jan 21, 2006, in forum: Microsoft Dot NET
    Replies:
    1
    Views:
    609
    Tim Wilson
    Jan 21, 2006
  8. caleprete60
    Replies:
    1
    Views:
    701
    PvdG42
    Nov 21, 2009
Loading...