Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# .NET Gridview DevExpress , +
Am getting error Unbound Expression. I Created a new column & Unbounded Expression on Runtime. I get a particular cell values(GetRowCellValue) from gridview and try to change that unbound expression column with new value(SetRowCellValue). But error shown whats my mistake ? Help me.
 
This is my Code.
 private void gridView1_CustomUnboundColumnData(object sender, DevExpress.XtraGrid.Views.Base.CustomColumnDataEventArgs e)
    {
 
            GridView view = sender as GridView;
 

            if (e.Column.FieldName == "PriceQuantity" && e.IsGetData)
            {
                //e.Value = getTotalValue(view, e.ListSourceRowIndex);
                calfun();
            }
            else
            {
                // nothing
            }
 
    }
 

    private void calfun()
    {
        if (gridView1.FocusedRowHandle >= 1)
        {
 
            string temp = "Discount";
            //string dis = TXE_Gettype.Text.ToString();
            object objec = gridView1.GetRowCellValue(gridView1.FocusedRowHandle, gridView1.Columns["Type"]);
            string dis = objec.ToString();
 
            if (dis == temp)
            {
                object obj = gridView1.GetRowCellValue(gridView1.FocusedRowHandle - 1, gridView1.Columns["Each"]);
 
                int aa = Convert.ToInt32(obj);
                //textEdit1.Text = aa.ToString();

                object obj1 = gridView1.GetRowCellValue(gridView1.FocusedRowHandle, gridView1.Columns["Each"]);
 
                int a = Convert.ToInt32(obj1);
                int b = aa;
 
                int c = a * b;
 
                //textEdit2.Text = c.ToString();

                gridView1.SetRowCellValue(gridView1.FocusedRowHandle, gridView1.Columns["PriceQuantity"], c);
            }
        }
        else
        {
            }
    }
Posted 25-Nov-13 2:53am
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

In nearly all situations, this exception is thrown as the result of "infinite" recursion, direct or indirect, or mutual recursion:
http://en.wikipedia.org/wiki/Recursion[^],
http://en.wikipedia.org/wiki/Recursion_(computer_science)[^],
http://en.wikipedia.org/wiki/Mutual_recursion[^].
 
I cannot immediately see the source of the problem, but such things are pretty easy found using the debugger. The key is using the Call Stack debug window. Please see my past answer for more detailed instruction on this process: System.Data.dll over flow[^].
 
—SA
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

I think you're supposed to set the value using e.Value = ...; instead of using SetRowCellValue. I would imagine SetRowCellValue would trigger the databind again, which calls calfun creating infinite recursion. Can't be sure unless I'd see the complete stack trace. But try using e.Value instead.
 
See also the sample at the documentation[^]:
 
private void gridView1_CustomUnboundColumnData(object sender, CustomColumnDataEventArgs e) {
    GridView view = sender as GridView;
    if (e.Column.FieldName == "Total" && e.IsGetData) 
        e.Value = getTotalValue(view, e.ListSourceRowIndex);
}
  Permalink  
Comments
srihari1904 at 26-Nov-13 0:33am
   
Hi ^Mo^, I need to perform two calculation 1) normally [Quantity * Each] this is done using
 
<pre lang="c#"> e.Value = getTotalValue(view, e.ListSourceRowIndex);</pre>
 
If the 1st column(RepositoryLookupEdit) in Gridview == ["Discount"] in this condition i need to perform other calculation. I want to get a cell value from previous row and get a cell value from current row and i need to multiply both & then set in a Unbound Column[PriceQuantity]. How to complete this task.

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

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 279
1 OriginalGriff 220
2 Peter Leow 205
3 _Amy 190
4 Andreas Gieriet 180
0 OriginalGriff 7,540
1 Sergey Alexandrovich Kryukov 6,412
2 Maciej Los 3,849
3 Peter Leow 3,653
4 CHill60 2,702


Advertise | Privacy | Mobile
Web01 | 2.8.140721.1 | Last Updated 25 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