Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4019708
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T10:08:17+00:00 2026-05-20T10:08:17+00:00

I have a database table with a sortOrder column. I display this list to

  • 0

I have a database table with a sortOrder column. I display this list to the user and they use jquery to resort the list, then save it back to the server.

After the reorder the list I get a new list in the correct order of all the IDs in that database table.

I need a good way to update this new sort order to the database. What I want is to query the database with a custom sort order based off this list of IDs I get back from the user. I can then step through that list and increment the sort order from 0.

Bonus points for code in VB, although C# is fine too.

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T10:08:18+00:00Added an answer on May 20, 2026 at 10:08 am

    You can’t store the sort order in the database unless you have a sort order field in the datatable (or an association with a sort order table that stores the original table’s field as an FK). If you have this field then in your linq query do, OrderBy(x=>x.SortOrder)

    So you have database record projection

       public class ObjectFromDb{
            int Id{get;set;}
            int SortOrder{get;set;}
       } 
    

    When you get the IQueryable<ObjectFromDb> queryable and the int[] newSortOrder , do this:

         var oldSortedList = queryable.OrderBy(x=>x.SortOrder).ToList()
         foreach(var i=0;i<oldSortedList.Count;i++;){
            oldSortedList[i].SortOrder = newSortOrder[i];
         }
         dataContext.SubmitChanges();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a database table, 'Reports'. Each column in this table is of type
I have a database table that has a SortOrder integer column. In the UI
i have database table like this +-------+--------------+----------+ | id | ip | date |
I have a Database table that I want to display in a DataGridView. However,
Suppose I have database table TABLE1 and there is Column COLUMN1 . The variable
I have a database table with a DATETIME column. What I want to do
i have database table with few text fields which i use to filter data
I have a database table that uses Sql Server 2005's uniqueidentifier column. I know
I have a database table structured like this (irrelevant fields omitted for brevity): rankings
I have a database table which holds each user's checkins in cities. I need

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.