0
votes

I am trying to create a gridcontrol with buttonedit in one of the columns. When the user clicks the button edit, it popups up a form to select a product. When the selection is done on the popup, It returns the DataRow from the selection to the main grid like below.

but when the column loses the focus, the value I wrote to the column disappear.

enter image description here

here is my code which creates the gridcontrol's data and buttonedit's click event.

    private void FrmSiparisNew_Load(object sender, EventArgs e)
    {
        dt = new DataTable();
        dt.Columns.Add("MALZEME_KODU",typeof(string));
        dt.Columns.Add("MALZEME_ACIKLAMA", typeof(string));
        dt.Columns.Add("ADET", typeof(decimal));
        dt.Columns.Add("BIRIM", typeof(string));
        dt.Columns.Add("FIYAT", typeof(decimal));
        dt.Columns.Add("KUR", typeof(string));
        dt.Columns.Add("TUTAR", typeof(decimal));
        DataRow dr = dt.NewRow();
        dt.Rows.Add(dr);

        gc.DataSource = dt;
    }

    private void repositoryItemButtonEditMalzemeKodu_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
    {
        FrmProducts frm = new FrmProducts(dt_products);
        frm.ShowDialog();

        DataRow dr_return = frm.dr;

        ButtonEdit buttonEdit = (sender as ButtonEdit);
        buttonEdit.Text = dr_return["URUNKOD"].ToString();

    }

why does the value disappear? should I first fill the datatable and bind it again? how can I fix this?

1
Like toddmo says, you need to update the underlying data source dt, and then use gc.RefreshDatasource(). It is probably unnecessary to update the ButtonEdit control. (Does dt really only have one row? If not, you can determine the correct row to update from e.RowNumber, or something similar - don't have a similar program in front of me right now.) - RenniePet

1 Answers

1
votes

It looks like the button edit is not connected intimately with the hosting grid. See if you can assign the value to the underlying grid cell or datatable row value. Then, it should stick.