473,396 Members | 1,766 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

DataGrid1_UpdateCommand (update price)

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
Nov 22 '05 #1
0 784

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: cwbp17 | last post by:
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...
5
by: cwbp17 | last post by:
Hi all, Have a datagrid that displays the price column of a table. Went to the Datagrid's Property builder and set the 'Data Formatting expression' for the PRICE column to {0:c}, so that the...
6
by: Manuel Canas | last post by:
Hello there, this is the piece of code that if giving problems right now; cnSQL = New SqlConnection(ConnectionString) **** strSQL = "UPDATE tb_product SET (ProductID = @cProductID, Code =...
0
by: Tom Grinnert | last post by:
Hello ! Im using a simple Datagrid in a C# VS 2002 Webapplication. If I change the String in "Item.Cells.Controls " the following code outputs after click on update: DataGrid being UPDATED...
2
by: SamDev | last post by:
I have a table that lists inventory items with prices and suppler and inventory description. There are times when a supplier will have a % increase of prices for all items so I want to be able to...
0
by: Jim in Arizona | last post by:
I'm experimenting by following instructions at this address: http://quickstarts.asp.net/QuickStartv20/aspnet/doc/ctrlref/data/datalist.aspx on how to use the DataList. I was trying out the...
1
by: imtmub | last post by:
Hi, I am new to asp.net. I have single page website that display the recordsin gridview from sql table. The table has 4 fields (wood, woodsize, price & woodtype). and i have added Boundcolumn for...
4
by: ebasshead | last post by:
Hi everybody, I've actually got my little database working (thanks to the scripts crew). But now I have to change some prices on some items, the thing is I dont want to change the price of...
13
by: Neil | last post by:
I'm running an update query in SQL 7 from QA, and it runs forever. Has been running for 20 minutes so far! The query is quite simple: update a single field in a table, based on a join with another...
3
by: pinko1204 | last post by:
My Update function cannot successful update to sql table even don't have any error. Please help to check .....thx PHP1 <?php require_once 'header.php'; ?> <style type="text/css"> <!--
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.