DataRepeater error when changing the data source

Answered Closed
0
0

For help.
I tried to reload the data source from the button click event of the DataRepeater Item and an error occurred.
How can I fix it?
Please refer to the attachment for specific code and operation screenshots.
thank you very much!

 
public partial class UserControl1 : Wisej.Web.UserControl
{
Random _rd = new Random();
List<Test> _source;
public UserControl1()
{
InitializeComponent();
button1.Click += Button1_Click;  //After this button was clicked, an error will be throw and it cannot be refreshed
button2.Click += Button2_Click;
}

private void Button1_Click(object sender, EventArgs e)
{
// After done something, then automatically refresh the data source.
ReLoadSource();
}

private void Button2_Click(object sender, EventArgs e)
{
// Load data for the first time or perform a data source refresh test.
// No errors…
ReLoadSource();
}

private void ReLoadSource()
{
_source = new List<Test>();
for (int i = 0; i < _rd.Next(5,50); i++)
{
_source.Add(new Test() { Name = $”Name{i}”, Title = $”T{i}”, IsCheck = (i % 2 == 0) });
}
label1.DataBindings.Clear();
checkBox1.DataBindings.Clear();
button1.DataBindings.Clear();

label1.DataBindings.Add(“Text”, _source, “Name”);
checkBox1.DataBindings.Add(“Checked”, _source, “IsCheck”);
button1.DataBindings.Add(“Text”, _source, “Title”);

dataRepeater1.DataSource = _source;
dataRepeater1.CurrentItem
}

}
public class Test
{
public string Name { get; set; }
public string Title { get; set; }
public bool IsCheck { get; set; }
}

  • You must to post comments
Best Answer
0
0

Confirmed to be a bug. Logged as bug #2450

The quick workaround is to add

FindPage().ActiveControl = null;

// or

FindForm().ActiveControl = null;

before setting the data source.

  • You must to post comments
0
0

This exception has been temporarily handled with you provided solution, and we look forward to product updates.
Thanks again!

  • You must to post comments
Showing 2 results