Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
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
0 OriginalGriff 459
1 Maciej Los 325
2 Sergey Alexandrovich Kryukov 234
3 DamithSL 233
4 BillWoodruff 200
0 OriginalGriff 7,168
1 Sergey Alexandrovich Kryukov 6,377
2 DamithSL 5,461
3 Manas Bhardwaj 4,876
4 Maciej Los 4,450


Advertise | Privacy | Mobile
Web01 | 2.8.1411023.1 | Last Updated 27 Nov 2013
Copyright © CodeProject, 1999-2014
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