0

I am developing a windows application using c# which uses DevExpress tools. I have a grid which contains more than one lookup edit in a single row. I have to bind each row in such a manner that when the first lookup edit changes then the adjacent lookup edit in the same row in bind. I can dynamically add rows with a ' Add Row' button.

How can I bind the second lookupEdit on the change of first lookup edit. On each look up value change only one row is affected all the previous should remain same.

I've been stuck for days - can anyone help me?

Thanks in advance.

Here is my workouts

private void leGridSubinventory_EditValueChanged(object sender, EventArgs e)
        {
            gvReservation.PostEditor();
            gvReservation.UpdateCurrentRow();
            GridView view = gvReservation;
            var obj = view.GetFocusedRow();
            int locationId = Common.intCast(leOutlets.EditValue);
            LookUpEdit sub = (LookUpEdit)sender;
            view.SetRowCellValue(view.FocusedRowHandle, view.Columns["itemId"], -1);
            view.SetRowCellValue(view.FocusedRowHandle, view.Columns["ItemDesc"], "");
            view.SetRowCellValue(view.FocusedRowHandle, view.Columns["PrimaryUOM"], "");
            view.SetRowCellValue(view.FocusedRowHandle, view.Columns["OnHandQty"], 0);
            view.SetRowCellValue(view.FocusedRowHandle, view.Columns["OnHandQty"], 0);
            if (sub.ItemIndex != -1)
            {
                int subId = Common.intCast(sub.EditValue);
                if (subId != -1)
                {
                    DataTable dtItems = cdm.GetAllItemsBySubinventory(locationId, subId);
                    DataRow locRow = dtItems.NewRow();
                    locRow["itemId"] = -1;
                    locRow["itemCode"] = "--Select--";
                    dtItems.Rows.InsertAt(locRow, 0);

                    rleItemCode.DataSource = dtItems;
                    rleItemCode.DisplayMember = "itemCode";
                    rleItemCode.ValueMember = "itemId";


                }
            }
        }
marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
M14
  • 1,780
  • 2
  • 14
  • 31

1 Answers1

1

As you know the lookuedit has the same datasource for all rows.
You need to update that datasource on 2 occasions
1)On the FocusRowChanged event of the gridview
2)On on the CellValueChanged event (for your first column)

So inside the above events call a function UpdateLokkupDatasource.
Inside this function get the focused row(so you can read the first field) and update the datasource

Don't forget to handle the CustomDisplayText event of the second lookupEdit(You will need this because so values will not exist in the new datasource)

George Vovos
  • 7,563
  • 2
  • 22
  • 45