Click here to Skip to main content
15,886,806 members
Please Sign up or sign in to vote.
1.22/5 (2 votes)
See more: , +
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.
C#
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

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
 
Share this answer
 
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[^]:

C#
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);
}
 
Share this answer
 
Comments
srihari1904 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)



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