0
  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);

              }

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.

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

1 Comment

Haha, no worries, debug is your friend :-)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.