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. LINQ
  4. problem in showing the column order in grid vb.net

problem in showing the column order in grid vb.net

Scheduled Pinned Locked Moved LINQ
csharpcssdatabasehelp
7 Posts 4 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.
  • N Offline
    N Offline
    Nilish
    wrote on last edited by
    #1

    I was running the select query to show eight columns in the grid. say dim query = from p in baseclass.Gettable(of tablename) _ select p.column1 , p.column12 , p.column3 , p.column4 , _ p.column5 , p.column6 , p.column7 , p.column8 when i bind it with the grid , it does not give the order of columns in grid , in which i placed them in the query. it shows in grid like p.column12 , p.column3 , p.column1 , p.column4 , p.column6 , p.column5 , p.column7 , p.column8

    H 1 Reply Last reply
    0
    • N Nilish

      I was running the select query to show eight columns in the grid. say dim query = from p in baseclass.Gettable(of tablename) _ select p.column1 , p.column12 , p.column3 , p.column4 , _ p.column5 , p.column6 , p.column7 , p.column8 when i bind it with the grid , it does not give the order of columns in grid , in which i placed them in the query. it shows in grid like p.column12 , p.column3 , p.column1 , p.column4 , p.column6 , p.column5 , p.column7 , p.column8

      H Offline
      H Offline
      Howard Richards
      wrote on last edited by
      #2

      Don't use AutoGenerateColumns, it won't work in VB.NET - manually define the columns in the grid.

      'Howard

      N 2 Replies Last reply
      0
      • H Howard Richards

        Don't use AutoGenerateColumns, it won't work in VB.NET - manually define the columns in the grid.

        'Howard

        N Offline
        N Offline
        Nilish
        wrote on last edited by
        #3

        i am using window application

        P 1 Reply Last reply
        0
        • N Nilish

          i am using window application

          P Offline
          P Offline
          Pete OHanlon
          wrote on last edited by
          #4

          Nilish wrote:

          i am using window application

          Good for you. And how does this relate to the advice you've been given?

          Deja View - the feeling that you've seen this post before.

          My blog | My articles

          H B 2 Replies Last reply
          0
          • P Pete OHanlon

            Nilish wrote:

            i am using window application

            Good for you. And how does this relate to the advice you've been given?

            Deja View - the feeling that you've seen this post before.

            My blog | My articles

            H Offline
            H Offline
            Howard Richards
            wrote on last edited by
            #5

            Indeed.. :-)

            'Howard

            1 Reply Last reply
            0
            • P Pete OHanlon

              Nilish wrote:

              i am using window application

              Good for you. And how does this relate to the advice you've been given?

              Deja View - the feeling that you've seen this post before.

              My blog | My articles

              B Offline
              B Offline
              Bassam Saoud
              wrote on last edited by
              #6

              :laugh: :laugh:

              1 Reply Last reply
              0
              • H Howard Richards

                Don't use AutoGenerateColumns, it won't work in VB.NET - manually define the columns in the grid.

                'Howard

                N Offline
                N Offline
                Nilish
                wrote on last edited by
                #7

                Hi , Please go through this code....

                BaseClassDataContext = New BaseClassDataContext(BLLmdlCommon.strConfiguration)

                        'Left outer join for extracting the project table records
                
                        Dim query = From p In BaseClassDataContext.GetTable(Of CP\_Project)() \_
                        Group Join crt In BaseClassDataContext.GetTable(Of CP\_CLM\_ClientRating)() \_
                        On p.RatingID Equals crt.RatingID Into ratingname = Group From c In ratingname.DefaultIfEmpty() \_
                        Group Join cname In BaseClassDataContext.GetTable(Of CP\_CLM\_Client)() \_
                        On cname.ClientID Equals p.ClientID Into clientname = Group From c1 In clientname.DefaultIfEmpty() \_
                        Group Join pstatus In BaseClassDataContext.GetTable(Of CP\_PRJ\_ProjectStatus)() \_
                        On pstatus.ProjectStatusID Equals p.ProjectStatusID Into projectstatus = Group From c2 In projectstatus.DefaultIfEmpty() \_
                        Group Join pjtype In BaseClassDataContext.GetTable(Of CP\_PRJ\_ProductType)() \_
                         On pjtype.ProductTypeID Equals p.ProductTypeID Into pj = Group From projecttype In pj.DefaultIfEmpty() \_
                        Select c.Rating, p.ProjectName, c1.ClientName, p.StartDate, p.DeliveryDate, c2.ProjectStatus, \_
                        p.ProjectID, c.RatingColor, projecttype.ProductType
                        'grdTasks.DataSource = query
                

                If i bind the grid now then i don't get the order of the column as i mentioned above Now instead of binding the grid now , if i create it's XML and convert into dataset . Then the order is correct.

                xElement = New XElement("Root", From p In query Select New XElement("Leaf", _
                New XElement("Rating", p.Rating), _
                New XElement("ProjectName", p.ProjectName), _
                New XElement("ClientName", p.ClientName), _
                New XElement("StartDate", p.StartDate), _
                New XElement("DeliveryDate", p.DeliveryDate), _
                New XElement("ProjectStatus", p.ProjectStatus), _
                New XElement("ProjectID", p.ProjectID), _
                New XElement("RatingColor", p.RatingColor), _
                New XElement("RatingColor", p.ProductType)))
                ds = New DataSet
                ds.ReadXml(New System.IO.StringReader(xElement.ToString()))

                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