Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Not considering "If condition in inside the foreach statement" [modified]

Not considering "If condition in inside the foreach statement" [modified]

Scheduled Pinned Locked Moved ASP.NET
5 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Member 3879881
    wrote on last edited by
    #1

    Hi my code not at all considering the if condition: Plz whats wrong in that code tell me..., foreach (DataRow drc in DS.Tables[DS.Tables.Count - 1].Rows) { int k = 0; while (k < drc.Table.Rows.Count) { if (drc.Table.Rows[k][1].ToString() == Path.GetFileNameWithoutExtension(d.Name)) { if (mbody.Length > 0) { mbody += ", "; } mbody += drc.Table.Rows[k][1].ToString(); } k++; } }

    Thanks & Regards, NeW OnE, please don't forget to vote on the post

    modified on Monday, July 28, 2008 6:32 AM

    B S 2 Replies Last reply
    0
    • M Member 3879881

      Hi my code not at all considering the if condition: Plz whats wrong in that code tell me..., foreach (DataRow drc in DS.Tables[DS.Tables.Count - 1].Rows) { int k = 0; while (k < drc.Table.Rows.Count) { if (drc.Table.Rows[k][1].ToString() == Path.GetFileNameWithoutExtension(d.Name)) { if (mbody.Length > 0) { mbody += ", "; } mbody += drc.Table.Rows[k][1].ToString(); } k++; } }

      Thanks & Regards, NeW OnE, please don't forget to vote on the post

      modified on Monday, July 28, 2008 6:32 AM

      B Offline
      B Offline
      Blue_Boy
      wrote on last edited by
      #2

      this if (drc.Table.Rows[k][1].ToString() == Path.GetFileNameWithoutExtension(d.Name)) is always false? Or if (mbody.Length > 0) return always 0 (zero) length ?


      I Love T-SQL "Don't torture yourself,let the life to do it for you."

      G 1 Reply Last reply
      0
      • B Blue_Boy

        this if (drc.Table.Rows[k][1].ToString() == Path.GetFileNameWithoutExtension(d.Name)) is always false? Or if (mbody.Length > 0) return always 0 (zero) length ?


        I Love T-SQL "Don't torture yourself,let the life to do it for you."

        G Offline
        G Offline
        gaurav mangal
        wrote on last edited by
        #3

        hi sir plz tell us why it will give false and 0 lenth always? thanks.... gaurav

        B 1 Reply Last reply
        0
        • M Member 3879881

          Hi my code not at all considering the if condition: Plz whats wrong in that code tell me..., foreach (DataRow drc in DS.Tables[DS.Tables.Count - 1].Rows) { int k = 0; while (k < drc.Table.Rows.Count) { if (drc.Table.Rows[k][1].ToString() == Path.GetFileNameWithoutExtension(d.Name)) { if (mbody.Length > 0) { mbody += ", "; } mbody += drc.Table.Rows[k][1].ToString(); } k++; } }

          Thanks & Regards, NeW OnE, please don't forget to vote on the post

          modified on Monday, July 28, 2008 6:32 AM

          S Offline
          S Offline
          Sherin Iranimose
          wrote on last edited by
          #4

          New one wrote:

          DS.Tables[DS.Tables.Count - 1].Rows

          If there is only one Table in the DS always, Why cant you use a DataTable.

          New one wrote:

          drc.Table.Rows[k][1].ToString()

          Set a break point a check what value is there in the above code.

          1 Reply Last reply
          0
          • G gaurav mangal

            hi sir plz tell us why it will give false and 0 lenth always? thanks.... gaurav

            B Offline
            B Offline
            Blue_Boy
            wrote on last edited by
            #5

            Because maybe he didn't debug his code.


            I Love T-SQL "Don't torture yourself,let the life to do it for you."

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups