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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. .NET (Core and Framework)
  4. Binding Collection to DataGrid

Binding Collection to DataGrid

Scheduled Pinned Locked Moved .NET (Core and Framework)
wpfwcfalgorithmshelp
3 Posts 3 Posters 2 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.
  • D Offline
    D Offline
    Derec Roofie
    wrote on last edited by
    #1

    Hi, I am using collection to bind data to datagrid. Dim oCars as CarCollections = New CarCollections DataGRid1.DataSource = oCars Everyithing work fine but there is a sorting problem. If I do so, there is no sorting features in DataGrid. When I bind DataSet to Datagrid I can Sort data in DataGrid by clicking on columns header. DataGRid automaticly sort filled data according clicked colum. When I bind datagrid to Collection that features is missing. What should i do, in Collection class - CarsCollection, to have sorting features back Thanks in advance P.S. Sorry for bad English ... Never argue with an idiot, they will drag you down to their level and beat you with experience

    S S 2 Replies Last reply
    0
    • D Derec Roofie

      Hi, I am using collection to bind data to datagrid. Dim oCars as CarCollections = New CarCollections DataGRid1.DataSource = oCars Everyithing work fine but there is a sorting problem. If I do so, there is no sorting features in DataGrid. When I bind DataSet to Datagrid I can Sort data in DataGrid by clicking on columns header. DataGRid automaticly sort filled data according clicked colum. When I bind datagrid to Collection that features is missing. What should i do, in Collection class - CarsCollection, to have sorting features back Thanks in advance P.S. Sorry for bad English ... Never argue with an idiot, they will drag you down to their level and beat you with experience

      S Offline
      S Offline
      Steven Campbell
      wrote on last edited by
      #2

      Try this article http://www.thecodeproject.com/csharp/datagridsort.asp.


      my blog

      1 Reply Last reply
      0
      • D Derec Roofie

        Hi, I am using collection to bind data to datagrid. Dim oCars as CarCollections = New CarCollections DataGRid1.DataSource = oCars Everyithing work fine but there is a sorting problem. If I do so, there is no sorting features in DataGrid. When I bind DataSet to Datagrid I can Sort data in DataGrid by clicking on columns header. DataGRid automaticly sort filled data according clicked colum. When I bind datagrid to Collection that features is missing. What should i do, in Collection class - CarsCollection, to have sorting features back Thanks in advance P.S. Sorry for bad English ... Never argue with an idiot, they will drag you down to their level and beat you with experience

        S Offline
        S Offline
        satya chhikara
        wrote on last edited by
        #3

        Try this sub method using own datagrid name Private Sub DataGrid2_SortCommand(ByVal source As System.Object, ByVal e As System.Web.UI.WebControls.DataGridSortCommandEventArgs) Dim dataGrid As DataGrid = source Dim strSort = dataGrid.Attributes("SortExpression") Dim strASC = dataGrid.Attributes("SortASC") dataGrid.Attributes("SortExpression") = e.SortExpression dataGrid.Attributes("SortASC") = "Yes" If e.SortExpression = strSort Then If strASC = "Yes" Then dataGrid.Attributes("SortASC") = "No" Else dataGrid.Attributes("SortASC") = "Yes" End If End If Dim dt As DataTable = getData() Dim dv As DataView = New DataView(dt) dv.Sort = dataGrid.Attributes("SortExpression") If dataGrid.Attributes("SortASC") = "No" Then dv.Sort &= " DESC" End If dataGrid.CurrentPageIndex = 0 dataGrid.DataSource = dv dataGrid.DataBind() End Sub

        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