473,671 Members | 2,570 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

DataGrid1_Updat eCommand (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_Updat eCommand event handler

string key = DataGrid1.DataK eys[e.Item.ItemInde x].ToString();

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

DataSet1.CAR_DE TAILRow r;

r = dataSet11.CAR_D ETAIL.FindByCAR _ID(int.Parse(k ey));

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

oracleDataAdapt er1.Update(data Set11);
DataGrid1.DataB ind();

DataGrid1.EditI temIndex = -1;
DataGrid1.DataB ind();

*************** ****
Can anyone tell me what I'm doing wrong? I've also tried using
Convert.ToDecim al 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
Jul 23 '05 #1
0 1730

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

Similar topics

5
4562
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 dollar sign, the comma, and the decimal are included (i.e. $44,644.48) Managed to update the price column of the datagrid back to the database, as long as, the user doesn't delete the dollar sign (in the 0 position).
6
1267
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 = @Code, ServiceName = @ServiceName, Price = @Price " & _ "WHERE ProductID = @cProductID)" ****
0
801
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 expression to {0:c} ********* Have the following code in the DataGrid1_UpdateCommand event handler string key = DataGrid1.DataKeys.ToString();
0
1073
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 - DataGrid1 : Item - 0 > OldString But the String I write to Grid was "NewString". Why did not show t.Text the
2
413
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 enter the price % increase and have a query update all inventory items for that supplier by the specified % increase. Not sure what is the best method - any suggestions - much thanks!
0
1149
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 update part and following the coding example almost line for line, except for changing some names of object to suit my own naming conventions. When I got to the Sub MyDataList_Update routine, they left out the update code. Below is the link to...
4
4831
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 any historical records, only new records should have the new price. I made a query to specify which product should have the new price after a certain date, and then changed it to an update query, and added the new price in the "update to" field which...
13
4165
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 table. There are a total of 1200 rows that are affected (out of a total of 60,000 in the table). Should not take 20 minutes! Also, retrieving the 1200 rows using the same criteria is instantaneous. Anyone have any idea what's going on? Here's...
3
2310
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
8485
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8930
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8677
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7446
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5704
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4417
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2819
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2062
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1816
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.