-
Lu Hui
- .NET DataStore
- Thursday, 30 July 2026 08:06 AM UTC
In .NET 10 C#, after obtaining data using the DataStore of DWNet.Data, it is bound to the DataGridView control through "new BindingSource { DataSource = dsUserlist };". Data editing is performed in the DataGridView control, and the dsUserlist.Update() method is called. The return value is 0. Upon investigation, it is found that the data in dsUserlist has indeed not changed. Why is this?
Adding "DataGridView.EndEdit();" and "bindingSource.EndEdit();" also
why?
/////////////////////////////////////
Bind DWNet.Data DataStore to DataGridView:
dsUserlist.Retrieve();
bindingSource = new BindingSource{ DataSource = dsUserlist };
dgvSystemParm.DataSource = bindingSource;
//////////////////////////////////////
DataStore Update:
try
{
dgvSystemParm.EndEdit();
bindingSource.EndEdit();
int rowsAffected = await dsUserlist.UpdateAsync(CancellationToken.None);
if (rowsAffected >= 0)
{
MessageBox.Show($"Data updated successfully, with a total impact of {rowsAffected} ");
}
else
{
MessageBox.Show("Cancel。");
}
}
catch (Exception ex)
{
MessageBox.Show($"Error: {ex.Message}");
}
finally
{
//this.Enabled = true;
}
Find Questions by Tag
Helpful?
If a reply or comment is helpful for you, please don’t hesitate to click the Helpful button. This action is further confirmation of their invaluable contribution to the Appeon Community.