Click here to Skip to main content
12,631,231 members (31,073 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: C# Gridview DevExpress
In my Gridview I set unbound Expresion([Price] * [Quantity]) to Unbound Column[Total] in property. In run time, If I select "Discount" 1st column(repository lookup edit) on gridview I perform another calculation([Price]*[Price]) then it will store in Unbound Column[Total]. If i select new row, all existing rows in the Unbound Column([Total]) will replace by new value. what was my error ?

my code is this


private void repositoryItemGridLookUpEdit1_EditValueChanged(object sender, EventArgs e)
   {
 
       GridLookUpEdit LookupEdit = sender as GridLookUpEdit;
       DataRowView SelectedDataRow = (DataRowView)LookupEdit.GetSelectedDataRow();
 

       getget = LookupEdit.EditValue.ToString();
 
       TXE_Gettype.Text = "";
       object obj = LookupEdit.EditValue.ToString();
       string obj2 = obj.ToString();
 
       TXE_Gettype.Text = obj.ToString();
       MessageBox.Show(obj2, "Information", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
 

       gridView1.SetFocusedRowCellValue("Description", SelectedDataRow["Description"]);
       gridView1.SetFocusedRowCellValue("UoM", SelectedDataRow["UoM"]);
       gridView1.SetFocusedRowCellValue("Quantity", SelectedDataRow["Quantity"]);
       gridView1.SetFocusedRowCellValue("Each", SelectedDataRow["Each"]);
 
       //gridView1.SetRowCellValue(textEdit1.Text, SelectedDataRow["Each"]);

        string sss="Discount";
        if (obj2 != sss)
        {
            object eachprice = gridView1.GetRowCellValue(gridView1.FocusedRowHandle, gridView1.Columns["Each"]); // Get the price of product from  previous row
            //decimal pricedecimal = Convert.ToDecimal(eachprice);

            textEdit1.Text = eachprice.ToString();
            MessageBox.Show("product price " + textEdit1.Text, "Information", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
        }
        else
        {
            //textEdit1.Text = "";
        }
 
       gridView1.SetFocusedRowCellValue("TaxPercentage", SelectedDataRow["TaxPercentage"]);
 

       int rownumber = gridView1.RowCount;
       if ((obj2 == sss) && (rownumber >= 1))
       {
 
           //object eachprice = gridView1.GetRowCellValue(rownumber - 1, gridView1.Columns["Each"]); // Get the price of product from  previous row
           if (!(textEdit1.Text == string.Empty))
           {
               decimal pricedecimal = Convert.ToDecimal(textEdit1.Text);
               object eachdiscount = gridView1.GetRowCellValue(gridView1.FocusedRowHandle, gridView1.Columns["Each"]);
               decimal eachdisdecimal = Convert.ToDecimal(eachdiscount);
               decimal tempdiscountprice = pricedecimal * (eachdisdecimal / 100);
               textEdit2.Text = tempdiscountprice.ToString();
           }
 
       }
       else
       {
          // textEdit2.Text = " ";
       }
 
   }
 

           private void gridView1_CustomUnboundColumnData(object sender, DevExpress.XtraGrid.Views.Base.CustomColumnDataEventArgs e)
                       {
               string str = "0";
 

                  // MessageBox.Show("Info be4 "+textEdit2.Text.ToString(), "Information", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
               //if ((TXE_Gettype.Text == "Discount") && (e.Column.FieldName == "PriceQuantity") && (e.IsGetData) && (str=="0"))

               if ((getget == "Discount") && (e.Column.FieldName == "PriceQuantity") && (e.IsGetData) && (str == "0"))
               {
                          e.Value = textEdit2.Text;
                          str = "1";
 
                       int s;
 
               }
               else
               {
                   //textEdit2.Text = "";
                   str = "0";
                   e.Value = "1212";
               }
 

           }
Posted 26-Nov-13 19:40pm

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.161205.3 | Last Updated 27 Nov 2013
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100