Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Feb 27, 2012 08:35 AM by superguppie
Jun 20, 2007 10:26 AM|LINK
At my GRIDVIEW I have 2 columns namely "unit price" and "quantity".
I want to display the product of these 2 columns in another field called "amount" on the GRIDVIEW.
I wish to display the calculated value in this third column once the user lost focus from “unit price” or “quantity”.
I will appreciate urgent help...please.
Jun 20, 2007 12:14 PM|LINK
Check the solution for a similar question at
Jun 20, 2007 06:04 PM|LINK
Thanks... thanks a lot.....
now i am at another problem. i want to save data to database from that gridview. can u help me by giving c# code?
Jun 20, 2007 08:39 PM|LINK
If you want to save the data to a MS SQL DB, I would suggest using a simple stored procedure. Then what you can do is databind the gridview to the SP and there you have it. You can save the data with virtually no code other than the SP.
If you have any ?'s on this, let us know
Mark As Answer If this has helped you
Jun 21, 2007 01:17 AM|LINK
thanks... can u provide me C# code??
Jun 21, 2007 05:12 AM|LINK
Check Data Tutorials of this site.
Jun 21, 2007 08:23 AM|LINK
thanks a lot again.... now another problem. at page load event i bound salesAmount column by 0(Grid View)...
when i want to save data to database the new calculated value(sales qty*price per qty) does not save... the default value doing save!!!!!
Jun 23, 2007 05:11 AM|LINK
.... now another problem. at page load event i bound salesAmount column by 0(Grid View)...
You need to keep your page load event code to bound salesAmount column in an IsPostBack check
if ( ! Page.IsPostBack )
// write your code here to bound the salesAmount
When you try to save the new calculated values, on the insert/update command, the page_load will be called first and your values are getting reset. If you use the PostBack check, the code is executed only the first time and not on subsequent postback's
Jun 23, 2007 12:43 PM|LINK
yes i did it......... BUT still remain same...
I cant understand what is the problem....... this problem is also to others 0 default valued fields...
string strSQL = "", strCon = "";
protected void Page_Load(object sender, EventArgs e)
strCon = ConfigurationManager.ConnectionStrings["DB_OrderConnectionString"].ConnectionString;
SqlConnection con = new SqlConnection(strCon);
//GET SERVER DATE
//this.lblEntryDate.Text = DateTime.Now.ToString("dd-MMM-yyyy");
//GET PRODUCT INFO
strSQL = "SELECT intProductCode, strProductName as ProductName, SKU, Pack, intQtyPerCase AS QtyPerCase, mnyCasePrice,
0 as QtyToDeliv, 0 as BonusQty, 0 as SalesAmnt, intBonusQtyPerCase FROM tblProductInfo ORDER BY strProductName, intProductCode";
SqlCommand cmdP = new SqlCommand(strSQL, con);
SqlDataAdapter AdapterP = new SqlDataAdapter(cmdP);
DataTable dtProduct = new DataTable();
this.GVChallanEntry.DataSource = dtProduct;
catch (Exception ex)
lblErr.Text = ex.Message;
if (lblErr.Text == "Line 1: Incorrect syntax near '='.")
lblErr.Text = ex.Message;
Dec 25, 2007 09:54 AM|LINK
i have solved this problem myself... thanks for help