Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/37.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
asp.net(C#)中网页中的表用法 int numcells=2; foreach(fileQuery中的System.IO.FileInfo-fi) { Label1.Text=fileList.Count().ToString(); TableRow r=新的TableRow(); 对于(int i=0;i_C#_Asp.net_File - Fatal编程技术网

asp.net(C#)中网页中的表用法 int numcells=2; foreach(fileQuery中的System.IO.FileInfo-fi) { Label1.Text=fileList.Count().ToString(); TableRow r=新的TableRow(); 对于(int i=0;i

asp.net(C#)中网页中的表用法 int numcells=2; foreach(fileQuery中的System.IO.FileInfo-fi) { Label1.Text=fileList.Count().ToString(); TableRow r=新的TableRow(); 对于(int i=0;i,c#,asp.net,file,C#,Asp.net,File,我尝试使用上述代码打印表中的文件名及其路径。 但由于某些原因,它没有打印表格。 语法有错误吗。 如果有人发现代码中的错误,请告诉我。i.Equals(“0”)和i.Equals(“1”)不正确,应该是i.Equals(0)和i.Equals(1) 这将解决您的问题,Equals用于确定指定的对象是否等于当前对象,在本例中不是因为“1”是字符串,1是整数 查看这里了解更多关于equals的信息哈哈,不用担心,debug是你的朋友:-) int numcells = 2;

我尝试使用上述代码打印表中的文件名及其路径。
但由于某些原因,它没有打印表格。
语法有错误吗。
如果有人发现代码中的错误,请告诉我。

i.Equals(“0”)
i.Equals(“1”)
不正确,应该是
i.Equals(0)
i.Equals(1)

这将解决您的问题,Equals用于确定指定的对象是否等于当前对象,在本例中不是因为“1”是字符串,1是整数


查看
这里
了解更多关于equals的信息

哈哈,不用担心,debug是你的朋友:-)
  int numcells = 2;


          foreach (System.IO.FileInfo fi in fileQuery)
          {
              Label1.Text = fileList.Count().ToString();


                  TableRow r = new TableRow();
                  for (int i = 0; i < numcells; i++)
                  {
                      if (i.Equals("0"))
                      {


                          TableCell c = new TableCell();
                          c.Controls.Add(new LiteralControl(fi.Name.ToString()));
                          r.Cells.Add(c);


                      }
                      if (i.Equals("1"))
                      {


                          TableCell c = new TableCell();
                          c.Controls.Add(new LiteralControl(Server.MapPath(strheadlinesid).ToString() + fi.Name.ToString()));
                          r.Cells.Add(c);
                      }
                      Table1.Rows.Add(r);

              }