Question

I'm currently attempting to use the Windows Powerpack DataRepeater control to display data from a DataTable.

So far, the DataRepeater recognizes that the resulting DataTable called from the Database has 8 rows, but I haven't been able to get the 3 textboxes (That I've put into the ItemTemplate of my DataRepeater) to show the actual data in said rows.

DataTable DT = BL.GetDataTable();
BindingSource bSource = new BindingSource();
bSource.DataSource = DT;
DR.DataSource = bSource;

txtEmail.DataBindings.Add("Text", bSource, "Email");
txtID.DataBindings.Add("Text", bSource, "ID");
txtName.DataBindings.Add("Text", bSource, "Name");

So, once the DataRepeater(DR) is viewed, you can see 8 rows. If the Textboxes are left to be a part of DR, then they get repeated on each of those 8 rows, but with no data.

If I remove the textboxes and place them on the form directly, then as a navigate through DR, the textboxes show the corresponding data. Which isn't the behaviour I'm looking for.

Does anyone know how to have the textboxes show the data, AND be a part of the DataRepeater?

Was it helpful?

Solution

I know it is a bit late, but stil if you haven't found the answer yet, I'll post this jost in case.

I had the same problem which I solved by binding elements to data first and only then did the datarepeater binding. So your code should look like this:

    txtEmail.DataBindings.Add("Text", "", "Email");
    txtID.DataBindings.Add("Text", "", "ID");
    txtName.DataBindings.Add("Text", "", "Name");

    DataTable DT = BL.GetDataTable();
    bSource.DataSource = DT;
    DR.DataSource = bSource;
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top