Hello, I have created a form using Data Repeater and have inserted some labels and textboxes. Firstly, I deserialized XML file into an object and bind it to the data repeater. I have also binded the labels and textboxes with the appropriate datatable columns. Here are my following codes:
These are the labels and textboxes binded to the data I want to display:
TagLabel.DataBindings.Add("Text", ds, "Tag");
PrecedenceLabel.DataBindings.Add("Text", ds, "Precedence");
DataTypeLabel.DataBindings.Add("Text", ds, "DataType");
LengthLabel.DataBindings.Add("Text", ds, "Length");
ValueTextBox.DataBindings.Add("Text", ds, "Value");
MaxTextBox.DataBindings.Add("Text", ds, "Maximum");
MinTextBox.DataBindings.Add("Text", ds, "Minimum");
OverflowTextBox.DataBindings.Add("Text", ds,"OverflowBehaviour");
bindingsource.DataSource = ds;
dataRepeater.DataSource = bindingsource;
dataRepeater.DataMember = "Preference";
After this, I want to hide some ValueTextbox if it's DataTypeLebel is "Autoinrement" with the following codes:
for (int i = 0; i < dataRepeater.ItemCount; i++)
{
dataRepeater.CurrentItemIndex = i;
if (((Label)dataRepeater.CurrentItem.Controls["DataTypeLabel"]).Text == "AutoIncrement")
{
((TextBox)dataRepeater.CurrentItem.Controls["ValueTextBox"]).Visible = false;
}
}
When the form is loaded, the row 5 ValueTextBox is hidden, which is correct. However, as I scroll down the form, some other ValueTextBoxes are also hidden, whhich are not correct. After a while the ValueTextBoxes are hidden on other rows and basically they are not maintained. Can anyone suggest what have I missed?