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. General Programming
  3. C#
  4. Code Sends Me To A New Page Before Completion

Code Sends Me To A New Page Before Completion

Scheduled Pinned Locked Moved C#
databasehelp
6 Posts 3 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.
  • P Offline
    P Offline
    PDTUM
    wrote on last edited by
    #1

    Hello, I have written a 2 page program. The first page connects to a remote database so that queries can be run from the second page. Once the connection is established, that second page is navigated to using a button that calls the ShowDialog command. On the second page, I construct a query from an assortment of listview boxes and send the results to a DataGridView. So far so good....everything works to this point. Now, I have a rich text box that shows the final SQL statement that was used to create the GridView. I want to be able to modify the command manually and run it again to get new results without leaving this page...seems simple enough...however, when I try to run the command the second time using a different run button, the first page reappears when the code is completed. I stepped through it and found that the program is sending me back to the first page and stopping in the button code that called the ShowDialog command; and then I am stuck there. I do not know why I am being forced to leave the second page and why the code doesn't simply run and put the new information into the DataGrid. Please tell me where I am going wrong.....Thank you in advance....Pat

    L B 2 Replies Last reply
    0
    • P PDTUM

      Hello, I have written a 2 page program. The first page connects to a remote database so that queries can be run from the second page. Once the connection is established, that second page is navigated to using a button that calls the ShowDialog command. On the second page, I construct a query from an assortment of listview boxes and send the results to a DataGridView. So far so good....everything works to this point. Now, I have a rich text box that shows the final SQL statement that was used to create the GridView. I want to be able to modify the command manually and run it again to get new results without leaving this page...seems simple enough...however, when I try to run the command the second time using a different run button, the first page reappears when the code is completed. I stepped through it and found that the program is sending me back to the first page and stopping in the button code that called the ShowDialog command; and then I am stuck there. I do not know why I am being forced to leave the second page and why the code doesn't simply run and put the new information into the DataGrid. Please tell me where I am going wrong.....Thank you in advance....Pat

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      Well, at a rough guess I would say there is either a code bug or a logic error in your program. However, without seeing some of your code it's difficult to be more precise.

      The best things in life are not things.

      P 1 Reply Last reply
      0
      • P PDTUM

        Hello, I have written a 2 page program. The first page connects to a remote database so that queries can be run from the second page. Once the connection is established, that second page is navigated to using a button that calls the ShowDialog command. On the second page, I construct a query from an assortment of listview boxes and send the results to a DataGridView. So far so good....everything works to this point. Now, I have a rich text box that shows the final SQL statement that was used to create the GridView. I want to be able to modify the command manually and run it again to get new results without leaving this page...seems simple enough...however, when I try to run the command the second time using a different run button, the first page reappears when the code is completed. I stepped through it and found that the program is sending me back to the first page and stopping in the button code that called the ShowDialog command; and then I am stuck there. I do not know why I am being forced to leave the second page and why the code doesn't simply run and put the new information into the DataGrid. Please tell me where I am going wrong.....Thank you in advance....Pat

        B Offline
        B Offline
        BobJanova
        wrote on last edited by
        #3

        ShowDialog returns when the form it calls is closed. So either the event handler on the second button is closing the modal form (directly or indirectly), or you have set a DialogResult on that button (which causes it to close the form).

        P 1 Reply Last reply
        0
        • L Lost User

          Well, at a rough guess I would say there is either a code bug or a logic error in your program. However, without seeing some of your code it's difficult to be more precise.

          The best things in life are not things.

          P Offline
          P Offline
          PDTUM
          wrote on last edited by
          #4

          Richard, Thank you for your reply....Yes, I agree with your input. There was so much code on this that I did not think it was OK to show it all, so I did not. I think that Bob (below) has an idea regarding the modality so I will pursue that line right now. In the meantime, I created a work around (which did not fix the issue but allowed me to get the desired result a different way). I wanted to reply though and thank you for taking the time to assist. I know you time is valuable and I appreciate it. Best Regards, Pat

          L 1 Reply Last reply
          0
          • B BobJanova

            ShowDialog returns when the form it calls is closed. So either the event handler on the second button is closing the modal form (directly or indirectly), or you have set a DialogResult on that button (which causes it to close the form).

            P Offline
            P Offline
            PDTUM
            wrote on last edited by
            #5

            Bob, Thank you for your reply. I will further examine the code as per your suggestion and post the solution if I am able to correct it. In the meantime, I have created a work around to solve the immediate problem, but I will not be happy until I understand the "why" of it so I can do it correctly next time. Best Regards, Pat

            1 Reply Last reply
            0
            • P PDTUM

              Richard, Thank you for your reply....Yes, I agree with your input. There was so much code on this that I did not think it was OK to show it all, so I did not. I think that Bob (below) has an idea regarding the modality so I will pursue that line right now. In the meantime, I created a work around (which did not fix the issue but allowed me to get the desired result a different way). I wanted to reply though and thank you for taking the time to assist. I know you time is valuable and I appreciate it. Best Regards, Pat

              L Offline
              L Offline
              Lost User
              wrote on last edited by
              #6

              No worries, hope you resolve your problem.

              The best things in life are not things.

              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