Note that there are some explanatory texts on larger screens.

plurals
  1. PORefresh DataSource and update GridControl
    primarykey
    data
    text
    <p>i will try to explain my problem here...</p> <p>I work with 2 forms. first one have Drop down menu and grid control that is populated after selecting item in drop down menu. after populating gridControl, I have a button to add new row with data. When i click it, new form opens with textFields to fill, and save button to save changes and refresh gridControl. Here is code from first form where gridControl is populated after select item in dropDown menu:</p> <pre><code>private void ddScoreType_EditValueChanged(object sender, EventArgs e) { ddScoreTypeSelectedID = Convert.ToInt32((sender as LookUpEdit).EditValue); try { gcScoreParam.DataSource = null; gvScoreParam.Columns.Clear(); selectedScoreType = _db.ScoreTypes.Where(x =&gt; x.ID == ddScoreTypeSelectedID).SingleOrDefault(); gcScoreParam.DataSource = selectedScoreType.ScoreParams.ToList(); gvScoreParam.Columns.AddVisible("Name", "Name"); gvScoreParam.Columns.AddVisible("Code", "Code"); } catch (Exception ex) { MessageBox.Show(ex.Message); } } </code></pre> <p>That works fine... Here is code from my second input form where i should add new data and refresh gridControl in first form:</p> <pre><code>private void btnSave_Click(object sender, EventArgs e) { //XtraMessageBox.Show("ID - " + _ScoresTypeID); db = new BetEntities(); ScoreParam param = new ScoreParam(); db.ScoreParams.Add(param); param.ScoreTypeID = _ScoresTypeID; param.Name = txtScoreName.Text; param.Code = txtScoreCode.Text.ToUpper(); db.SaveChanges(); frmScoreType frmST = new frmScoreType(); frmST.RefreshGVParams(db); this.Close(); } </code></pre> <p>db is my database and ScoreParam is table. Here is method RefreshGVParams:</p> <pre><code>public void RefreshGVParams(BetEntities be) { //gvScoreParam.BeginDataUpdate(); gcScoreParam.BeginUpdate(); try { gcScoreParam.DataSource = null; // this line DOES NOT set datasource to null selectedScoreType = be.ScoreTypes.Where(x =&gt; x.ID == ddScoreTypeSelectedID).SingleOrDefault(); gcScoreParam.DataSource = selectedScoreType.ScoreParams.ToList(); gvScoreParam.Columns.Clear(); gvScoreParam.Columns.AddVisible("Name", "Name"); gvScoreParam.Columns.AddVisible("Code", "Code"); } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { gcScoreParam.EndUpdate(); //gvScoreParam.EndDataUpdate(); } } </code></pre> <p>I commented the line that doesn't set dataSource to null, and gridcontrol is not refreshed with new data... when i close my first form and start it again, then i see it refreshed with new data...</p> <p>How can i refresh gridControl in first form after clicking SAVE button in second form ? Where I made misstake ?</p> <p>Sorry for long post, but it's been 2 days since i can't solve this problem... I hope I explained well :)</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload