Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Senior Coder DanInMa's Avatar
    Join Date
    Nov 2010
    Location
    Salem,Ma
    Posts
    1,577
    Thanks
    13
    Thanked 248 Times in 248 Posts

    Listview reordering position in list oninsert and onchange

    basic idea first. I have a table with several fields, the 2 important ones being "ID" and "Postion" . There will only be 4 entries in the table. ( they are links that will go on parts of specific pages).
    The position is 1,2,3 or 4.

    Things I need to figure out

    - How do I limit the maximum number of records to 4? ( more of an mssql question I suppose)
    - Ondatabind how do I hide the insert row if there are a total of 4 items in the table. ( to prevent the user from attempting to do so)
    - when the user changes the position field of a row to a different number ( using a dropdown list), how do I then reorder the other rows in the table ?


    - on the front end the Position field determines the position the links go into an unordered list for display ( jsut so you understand what Im trying to do)

    I assume I should somehow indicate that the position row in the table should have distinct/unique values? I will take example but Id prefer tutorials. If you can help with even one piece of this Im glad for the assistance.
    In regards to reordering the list, I'm sure it's a common enough task but I don't know what the terminology for the process would be so I didnt have much success with google.

    - Im using c# on 4.0 framework

  • #2
    Senior Coder DanInMa's Avatar
    Join Date
    Nov 2010
    Location
    Salem,Ma
    Posts
    1,577
    Thanks
    13
    Thanked 248 Times in 248 Posts
    - Ondatabind how do I hide the insert row if there are a total of 4 items in the table. ( to prevent the user from attempting to do so)

    well i figured out how to do this part so far.

  • #3
    Senior Coder alykins's Avatar
    Join Date
    Apr 2011
    Posts
    1,742
    Thanks
    41
    Thanked 191 Times in 190 Posts
    are you creating a datatable first and then binding the datatable to the gridview? you don't need to databind the gridview to the database. You can populate a datatable and then manipulate it any way you want, then bind it to the gridview... see my reply in this thread... although I answered the OP wrong, the logic is correct- i just didn't understand the OP question correctly :P

    Does that help?

    I code C hash-tag .Net
    Reference: W3C W3CWiki .Net Lib
    Validate: html CSS
    Debug: Chrome FireFox IE

  • #4
    Senior Coder DanInMa's Avatar
    Join Date
    Nov 2010
    Location
    Salem,Ma
    Posts
    1,577
    Thanks
    13
    Thanked 248 Times in 248 Posts
    nope the table is already created. each row has a column "position" , position should be limited to 1-4. lets say I change record 1 from position value of 1 to a value of 3, then i want to change the position value in record 2 to 1, record 3 to position 2, record 1 to position 3 and record 4 to position 4.

    I have limited the listview to show a maxaimum of 4 items and if there are 4 items the insert option no longer shows, so they cant go over 4.

    if you need to see my table setup or anything at all sut ask, im not sure what would be most helpful.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •