Click here to Skip to main content
15,891,136 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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


C#
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

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900