如何在c#循环中更改数据视图过滤器 [英] how to change dataview filter in loop in c#

查看:70
本文介绍了如何在c#循环中更改数据视图过滤器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我的程序中有一个数据视图,我在for循环中为dataview添加了filte,当这个循环完成第一次迭代时,然后删除fiter并添加一个新的过滤器。这个工作正常,第一次迭代,但第二次迭代它不工作..



代码如下:



  DataView  dv1; 
dv1 = new DataView (records.Tables [2])
int i = 1;
while(i< = 3)
{

dv1 RowFilter = teamno =+ i;
reqcls = 0;
// 带过滤记录的一些功能(i = 1,2,3)
................
................
dv1 RowFilter = null;
i ++;

}





第一次迭代(当i = 1)这个工作正常,但是在第二次迭代中它会循环出来..



提前谢谢..

解决方案

如果循环结束,则满足条件。正如其他人所说,逐步调试调试器中的代码(F9设置断点,F5调试)。


 //带过滤记录的一些功能(i = 1 ,2,3)





检查在此声明中是否增加了i的值

Hi everyone,
I have a data view in my program, and I have added filte to dataview in for loop, when this loop completes it first iteration, then it delete the fiter and add a new filter..This working fine for first iteration but for 2nd iteration it is not working..

The code is as follows:

DataView dv1;
dv1 = new DataView(records.Tables[2])
int i=1;
while(i<=3)
{

dv1.RowFilter = "teamno=" +i;
reqcls = 0;
// Some functionality with filtered records(i=1,2,3)
................
................
dv1.RowFilter = null;
i++;

}



In first iteration(when i=1) this is working fine, but in the second iteration it is coming out of loop..

Thanks in advance..

解决方案

If the loop is ending, then the condition is met. As others have said, step through the code in the debugger ( F9 sets a breakpoint, F5 debugs ).


// Some functionality with filtered records(i=1,2,3)



check if in this statement you have incremented the value of i


这篇关于如何在c#循环中更改数据视图过滤器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆