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. Move Up And Down rows in datagridview and update it in database

Move Up And Down rows in datagridview and update it in database

Scheduled Pinned Locked Moved C#
databasewpfwcfhelptutorial
6 Posts 2 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.
  • U Offline
    U Offline
    User 13293914
    wrote on last edited by
    #1

    Hi,savers. i can move my row but after binding it will back to the previous state. how can i update it to my database e.g the second row become third row in both datagridview and database and also the ID column become update (resort assending from 1 to the end and 2become3 and 3become2) in my database(i can update that in datagridview by a foreach loop). please help me..... :(( :(( please guide me by your codes :-\ :-\ . thank you in advance.

    L 1 Reply Last reply
    0
    • U User 13293914

      Hi,savers. i can move my row but after binding it will back to the previous state. how can i update it to my database e.g the second row become third row in both datagridview and database and also the ID column become update (resort assending from 1 to the end and 2become3 and 3become2) in my database(i can update that in datagridview by a foreach loop). please help me..... :(( :(( please guide me by your codes :-\ :-\ . thank you in advance.

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

      Add a column to the table and specify a value to determine the order, or create an index. Don't try to "order" rows in a database-table. A database is not meant for direct viewing, and the order in which it is stored is not related to the way it is shown.

      Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^]

      U 1 Reply Last reply
      0
      • L Lost User

        Add a column to the table and specify a value to determine the order, or create an index. Don't try to "order" rows in a database-table. A database is not meant for direct viewing, and the order in which it is stored is not related to the way it is shown.

        Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^]

        U Offline
        U Offline
        User 13293914
        wrote on last edited by
        #3

        thank you so much for your answer. i have to sort them in my database because some calculation will perform in the DBS that data sorting and ID Numbers are very important. thank you any way to care about my question. i'll be grateful if you add your comments if anything else ocured to your mind. :-O :-O :thumbsup:

        L 1 Reply Last reply
        0
        • U User 13293914

          thank you so much for your answer. i have to sort them in my database because some calculation will perform in the DBS that data sorting and ID Numbers are very important. thank you any way to care about my question. i'll be grateful if you add your comments if anything else ocured to your mind. :-O :-O :thumbsup:

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

          Member 13325846 wrote:

          i have to sort them in my database

          Rows in a database have no particular order. You can specify the order when fetching the rows, or if you want to save a user-defined "order", you add that column. Don't muck with the order that the rows are saved in.

          Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^]

          U 1 Reply Last reply
          0
          • L Lost User

            Member 13325846 wrote:

            i have to sort them in my database

            Rows in a database have no particular order. You can specify the order when fetching the rows, or if you want to save a user-defined "order", you add that column. Don't muck with the order that the rows are saved in.

            Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^]

            U Offline
            U Offline
            User 13293914
            wrote on last edited by
            #5

            Hi, thank you for you guide my friend. best wishes. :rose::rose::rose:

            L 1 Reply Last reply
            0
            • U User 13293914

              Hi, thank you for you guide my friend. best wishes. :rose::rose::rose:

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

              You're welcome :)

              Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^]

              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