런타임에 DataRepeater (Windows PowerPack)에 DataTable을 어떻게 바인딩 할 수 있습니까?

StackOverflow https://stackoverflow.com/questions/6046499

문제

현재 Windows PowerPack Datarepeater 컨트롤을 사용하여 데이터를 표시 할 수있는 데이터를 표시하려고합니다.

지금까지 DataRepeater는 데이터베이스에서 호출 된 데이터베이스에서 호출 된 데이터베이스에서 8 개의 행이 있음을 인식하지만 실제를 보여주기 위해 3 개의 텍스트 상자를 얻을 수 없었습니다.상기 행의 데이터.

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");
.

그래서 DataRepeater (DR)를 볼 때 8 행을 볼 수 있습니다.텍스트 상자가 DR의 일부가되도록 남아 있으면 각 8 행 각각에서 반복됩니다. 그러나 데이터가 없었습니다.

텍스트 상자를 제거하고 양식에 직접 배치 한 다음 DR을 탐색하면 텍스트 상자에 해당 데이터가 표시됩니다.내가 찾고있는 행동은 아닙니다.

텍스트 상자가 데이터를 표시하고 DataRepeater의 일부가되는 방법을 알고 있습니까?

도움이 되었습니까?

해결책

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;
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top