実行時にDatayPeater(Windows PowerPack)にDataTableをバインドする方法を教えてください。

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

質問

現在、Windows PowerPack DataRepeatherコントロールを使用してデータをデータベース可能なデータを表示しようとしています。

これまでのところ、データベースから呼び出される結果のデータベースが8行があることを認識していますが、実際のテンプボックス(My DataRepeaterのitemtemperateに入ったこと)を取得できなかったことを認識していません。上記行のデータ

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行のそれぞれで繰り返されますが、データなしではありません。

TextBoxesを直接削除してから直接フォームに配置した場合、TextBoxesは対応するデータを表示します。私が探している行動ではありません。

誰もがテキストボックスにデータを表示する方法を知っていて、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