Chr*_*ian 2 c# datatable datarepeater powerpacks
我目前正在尝试使用Windows Powerpack DataRepeater控件来显示DataTable中的数据.
到目前为止,DataRepeater认识到从数据库调用的结果DataTable有8行,但是我无法获得3个文本框(我已将其放入DataRepeater的ItemTemplate中)以显示实际数据行.
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");
Run Code Online (Sandbox Code Playgroud)
因此,一旦查看DataRepeater(DR),您就可以看到8行.如果文本框留下作为DR的一部分,那么它们将在这8行中的每一行上重复,但没有数据.
如果我删除文本框并将它们直接放在表单上,那么在浏览DR时,文本框会显示相应的数据.这不是我正在寻找的行为.
有谁知道如何让文本框显示数据,并成为DataRepeater的一部分?
小智 5
我知道这有点晚了,但如果你还没有找到答案,我会发布这个jost以防万一.
我遇到了同样的问题,我通过首先将数据绑定到数据来解决,然后才进行datarepeater绑定.所以你的代码应该是这样的:
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;
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3898 次 |
| 最近记录: |