code writes to a column but TextBox.Text doesn't refresh for new row

  • Thread starter Thread starter AlanChong
  • Start date Start date
A

AlanChong

Guest
Hello All. My program deals with only a row of data at a time. It reads a row of data from database. It modifies the "CustomerId" field and the databound TextBox.Text gets refreshed at once.
When it adds data it reads zero row with a where clause [CustomerId=]. DataTable.Rows.Count is zero now. It then

DataRow row = ds.Tables[0].NewRow();
ds.Tables[0].Rows.Add(row);

// the user presses a button to choose a Customer Id and brings back a value (same code for new or edit state)
ds.Tables[0].Rows[0]["CustomerId"] = form.GetValue("CustomerId");

The TextBox.Text doesnt get refreshed. It is still empty. I have to call

bindingsource1.resetBindings(false);

for the TextBox to get refreshed. This only happens with newly added row, but not any row loaded from database (edit state). Do you know why only a new row has this problem? I have a lot of dlls that write to datacolumns directly. I do not want to use that may resetBindings(false). Can I do something to make a newly added row behave just like a already existing row ? Thank all.

Continue reading...
 
Back
Top