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

  • Home
  • SEARCH
  • 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 4052300
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T14:18:11+00:00 2026-05-20T14:18:11+00:00

I am binding a Gridview to a custom object. But the order of fields

  • 0

I am binding a Gridview to a custom object.
But the order of fields displayed is not correct.
Is there any way to set the fields display order when binding a Gridview to a custom object?

Thanks in advance.

  • 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-20T14:18:11+00:00Added an answer on May 20, 2026 at 2:18 pm

    It is not even guaranteed that the order is the same as the declaration order of the properties in your custom object as MS exposes:

    “The GetProperties method does not return properties in a particular order, such as alphabetical or declaration order. Your code must not depend on the order in which properties are returned, because that order varies.”

    You should order it by yourself for example with Array.Sort. Here are some further informations and also an example on hot to ensure that it’s ordered by declaration: http://www.sebastienmahe.com/v3/seb.blog/2010/03/08/c-reflection-getproperties-kept-in-declaration-order/
    With Linq its even simplier:

    type.GetProperties().OrderBy(x=>x.MetadataToken)
    

    To order your custom object it needs to implement IComparable or you have to provide an IComparer as parameter for the Sort-Function.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the GridView below. I am binding to a custom datasource in the
I have a List of custom object, which consist of a custom list. class
I have custom objects I am binding to using ObjectDataSource. I have three-level binding:
I'm binding a datatable to a gridview control, and when I format each column
My ListView is petty simple: <ListView ItemsSource={Binding Path=ActiveCounters}> <ListView.View> <GridView> <GridViewColumn Header=Name DisplayMemberBinding={Binding Path=Name}
I have a list binding on a gridview. HistoryGrid.DataSource = objGrid; HistoryGrid.DataBind(); AllowSorting=true AllowPaging=True
I am attempting to bind a GridView to a DataSet, but it throws a
I am updating an existing ASP .NET site. This site has a custom grid
I have a custom control that is derived from ListView . This list view
How do I programmatically bind data to a custom item template column for a

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.