c# - how to use the foreach loop to pass each row of a wpf datagridview with Thesame data source as a report back to the report
问题描述
how can i bind my report/report Viewer to a datagrid view with the Data source as that of the report dataset? ive created an ID card design in a Report. I bind all textbox in the report in my database fields(Data set). but when i run the program, the reportViewer only displays the data from the first rowof my database.
Now, I want to bind my report to a datagrid so i can control which row i am going to display in the reportViewer.
i have search the internet so far this is what i found;
DataTable dtRep = ((DataTable)dgv.DataSource).Clone();
foreach (DataGridViewRow row in dgv.SelectedRows)
{
dtRep.ImportRow(((DataTable)dgv.DataSource).Rows[row.Index]);
}
dtRep.AcceptChanges();
but this doesn't work in wpf can some one help me with a code that could help me accomplish this? (thanks)
UPDATE am very sorry i run out of credit while uploading the question please pardon my ignorance;
HERE IS the image of my error from my code;
DataTable dtRep = ((DataTable)dgvRESULTPRINTER.ItemsSource).Clone();
foreach (DataGridViewRow row in dgvRESULTPRINTER.SelectedItems)
{
dtRep.ImportRow(((DataTable)dgvRESULTPRINTER.DataSource).Rows[row.Index]);
}
dtRep.AcceptChanges();
解决方案
推荐阅读
- sql - MSACCESS - 如何使用查询生成表添加主键
- ios - SwiftUI UIViewRepresentable 尊重约束
- c# - ViewData 以红色突出显示但我认为是我的模型为空?
- r - 估计没有随机效应的固定效应
- ios - 在 ios 应用程序中使用versaplayer 播放视频
- python - 将csv数据转换为dict而不将文件写入磁盘
- javascript - 有没有一种方法可以生成 25 个函数,同时增加它们而不是编写每个函数?
- python - 如何修复错误TypeError:需要一个类似字节的对象,而不是'str'?
- scala - 如何在 mac 上获取 typesafe-activator 1.3.6
- javascript - v-if 条件未从计算属性更新