Hello, I created a form with data repeater and in the data repeater I have some labels and textboxes. I have binded the labels and textboxes to a dataset which is created using the following codes:
<pre>private DataSet createDataSet(ProgrammingConfiguration pc)
{
ds = new DataSet("Preferences");
DataTable table = new DataTable("Preference");
table.Columns.Add("Tag");
table.Columns.Add("Precedence");
table.Columns.Add("DataType");
table.Columns.Add("Length");
table.Columns.Add("Value");
table.Columns.Add("Maximum");
table.Columns.Add("Minimum");
table.Columns.Add("OverflowBehaviour");
for (int i = 0; i < pc.Preferences.Length; i++)
{
if (pc.Preferences[i].Value.ItemElementName == ItemChoiceType.AutoIncrement)
{
ValueTypeAutoIncrement incrementalData = (ValueTypeAutoIncrement)pc.Preferences[i].Value.Item;
table.Rows.Add(pc.Preferences[i].Tag, pc.Preferences[i].Precedence, pc.Preferences[i].Value.ItemElementName, pc.Preferences[i].Value.Length,
"", incrementalData.Maximum, incrementalData.Minimum, incrementalData.OverflowBehaviour);
}
else
{
table.Rows.Add(pc.Preferences[i].Tag, pc.Preferences[i].Precedence, pc.Preferences[i].Value.ItemElementName, pc.Preferences[i].Value.Length, pc.Preferences[i].Value.Item);
}
}
ds.Tables.Add(table);
return ds;
}
I bind the controls with the following methods:
private void bindControls()
{
bindingsource = new BindingSource();
bindingsource.DataSource = ds;
TagLabel.DataBindings.Clear();
PrecedenceLabel.DataBindings.Clear();
DataTypeLabel.DataBindings.Clear();
LengthLabel.DataBindings.Clear();
ValueTextBox.DataBindings.Clear();
MaxTextBox.DataBindings.Clear();
MinTextBox.DataBindings.Clear();
OverflowComboBox.DataBindings.Clear();
TagLabel.DataBindings.Add(new Binding("Text", bindingsource, "Tag"));
PrecedenceLabel.DataBindings.Add(new Binding("Text", bindingsource, "Precedence"));
DataTypeLabel.DataBindings.Add(new Binding("Text", bindingsource, "DataType"));
LengthLabel.DataBindings.Add(new Binding("Text", bindingsource, "Length"));
ValueTextBox.DataBindings.Add(new Binding("Text", bindingsource, "Value", false, DataSourceUpdateMode.OnPropertyChanged));
MaxTextBox.DataBindings.Add(new Binding("Text", bindingsource, "Maximum", false, DataSourceUpdateMode.OnValidation));
MinTextBox.DataBindings.Add(new Binding("Text", bindingsource, "Minimum", false, DataSourceUpdateMode.OnValidation));
OverflowComboBox.DataBindings.Add(new Binding("SelectedItem", bindingsource, "OverflowBehaviour", false, DataSourceUpdateMode.OnPropertyChanged));
dataRepeater.DataSource = bindingsource;
dataRepeater.DataMember = "Preference";
}
I want to edit the ValueTextBox and change its value. However, as soon as I leave the textbox, the value is reset back to its original value. I pressume the dataset is not updated with the new value. Can anyone suggest how to achieve updating the dataset when textbox is updated please?