开发者

Table usage in the webpage in asp.net(C#)

开发者 https://www.devze.com 2023-03-10 02:16 出处:网络
int numcells = 2; foreach (System.IO.FileInfo fi in fileQuery) { Label1.Text = fileList.Count().ToString();
  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"))
                      {


                          Tab开发者_高级运维leCell 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);

              }

I tried with the above code to print file name and and its path in the table.

But for some reason it's not printing the table.

Is there any wrong in the syntax.

Please let me know the wrong in the code if anyone finds it.


i.Equals("0") and i.Equals("1") is incorrect and should be i.Equals(0) and i.Equals(1)

This will sort out your problem, Equals is used to determine if the specified object is equal to the current object, and in this case it is not because "1" is a string and 1 is an integer.

have a look here for more info on equals

0

精彩评论

暂无评论...
验证码 换一张
取 消