在循环内调用函数但循环停止 - c#(Calling function inside a loop but the loop stops - c#) for (int i = 0; i < dt.Rows.Count; i++) { function(dt.Rows[i][0].ToString()); }

我试图从gridview循环选定的值并将其放在数据表中。 现在,我的问题是当我尝试上面的代码将值从datatable传递给我的函数时。 它工作,但只有一次,循环停止。 有人可以帮帮我吗?

该功能用于下载pdf文件。

for (int i = 0; i < dt.Rows.Count; i++) { function(dt.Rows[i][0].ToString()); }

I tried to loop the selected values from the gridview and put it inside a datatable. Now, my problem is that when I tried the code above to pass the value from datatable to my function. It works, but just once and the loop stops. Can somebody help me please?

The function is for downloading pdf file.

最满意答案

如果函数正在将二进制pdf文件发送到响应流,则它可能正在调用Response.End ,这将停止该线程。

如果要发送多个文件,客户端需要发出多个请求,或者服务器需要打包它们,就像在zip文件中一样。

If the function is sending a binary pdf file to the response stream, it may be calling Response.End which would halt the thread.

If you want to send multiple files the client needs to make multiple requests or the server needs to package them up, like in a zip file.

在循环内调用函数但循环停止 - c#(Calling function inside a loop but the loop stops - c#) for (int i = 0; i < dt.Rows.Count; i++) { function(dt.Rows[i][0].ToString()); }

我试图从gridview循环选定的值并将其放在数据表中。 现在,我的问题是当我尝试上面的代码将值从datatable传递给我的函数时。 它工作,但只有一次,循环停止。 有人可以帮帮我吗?

该功能用于下载pdf文件。

for (int i = 0; i < dt.Rows.Count; i++) { function(dt.Rows[i][0].ToString()); }

I tried to loop the selected values from the gridview and put it inside a datatable. Now, my problem is that when I tried the code above to pass the value from datatable to my function. It works, but just once and the loop stops. Can somebody help me please?

The function is for downloading pdf file.

最满意答案

如果函数正在将二进制pdf文件发送到响应流,则它可能正在调用Response.End ,这将停止该线程。

如果要发送多个文件,客户端需要发出多个请求,或者服务器需要打包它们,就像在zip文件中一样。

If the function is sending a binary pdf file to the response stream, it may be calling Response.End which would halt the thread.

If you want to send multiple files the client needs to make multiple requests or the server needs to package them up, like in a zip file.