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. WPF
  4. populate datagrid

populate datagrid

Scheduled Pinned Locked Moved WPF
csshelpquestiondiscussion
8 Posts 2 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.
  • A Offline
    A Offline
    arkiboys
    wrote on last edited by
    #1

    Hi, I am trying to populate a grid on the silverlight page: as follows: ... ... grid.ItemsSource = e.Result.DetailedData; Note that e.Result.DetailedData.count returns 13 records but on the above line I get the error: can not implicitly convert type 'xweb.tservice.clsbt' to system.collections.ienumerable. An explicit conversion exists. (Are you missing a cast?) It seems I have to do a cast but not sure how? Any thoughts please? Thanks

    V 1 Reply Last reply
    0
    • A arkiboys

      Hi, I am trying to populate a grid on the silverlight page: as follows: ... ... grid.ItemsSource = e.Result.DetailedData; Note that e.Result.DetailedData.count returns 13 records but on the above line I get the error: can not implicitly convert type 'xweb.tservice.clsbt' to system.collections.ienumerable. An explicit conversion exists. (Are you missing a cast?) It seems I have to do a cast but not sure how? Any thoughts please? Thanks

      V Offline
      V Offline
      V 0
      wrote on last edited by
      #2

      In wpf I put my ItemsSource="{Binding}" in XAML. In code you then do : grid.ItemsSource = my_collection_of_some_sort; hope this helps.

      V.

      A 1 Reply Last reply
      0
      • V V 0

        In wpf I put my ItemsSource="{Binding}" in XAML. In code you then do : grid.ItemsSource = my_collection_of_some_sort; hope this helps.

        V.

        A Offline
        A Offline
        arkiboys
        wrote on last edited by
        #3

        the datagrid is set as AutoGenerateColumns="False" And still get the same error as before but this time there is a blue underline instead of the previous red underline.

        V 2 Replies Last reply
        0
        • A arkiboys

          the datagrid is set as AutoGenerateColumns="False" And still get the same error as before but this time there is a blue underline instead of the previous red underline.

          V Offline
          V Offline
          V 0
          wrote on last edited by
          #4

          In XAML

          In code behind.

          lv_countries.DataContext = countrylistresponse.CountryList;

          where countrylistresponse.CountryList is an array of Country class. Country class has two properties: Code and Name (see XAML) I'm not sure what kind of type e.Result.DetailedData is. You could try setting AutoGenerateColumns to "True" or define the columns in XAML. PS: I know my sample is a ListView, but the principle is the same. Note however that WPF and Silverlight are slightly different. Could be that you have to call eg "DataBind()" method like you have to don in Aspx. I don't know. If VS gives you a blue bar under the statement it should tell you something when you hover over the statement... hope this helps.

          V.

          1 Reply Last reply
          0
          • A arkiboys

            the datagrid is set as AutoGenerateColumns="False" And still get the same error as before but this time there is a blue underline instead of the previous red underline.

            V Offline
            V Offline
            V 0
            wrote on last edited by
            #5

            For the record In wpf I put my ItemsSource="{Binding}" in XAML. In code you then do : grid.ItemsSource = my_collection_of_some_sort; Should have been: In wpf I put my ItemsSource="{Binding}" in XAML. In code you then do : grid.DataContext = my_collection_of_some_sort; Make sure that the e.Result.DetailedData is a collection like a List, Dictionary or an array. Sorry about the confusion.

            V.

            A 1 Reply Last reply
            0
            • V V 0

              For the record In wpf I put my ItemsSource="{Binding}" in XAML. In code you then do : grid.ItemsSource = my_collection_of_some_sort; Should have been: In wpf I put my ItemsSource="{Binding}" in XAML. In code you then do : grid.DataContext = my_collection_of_some_sort; Make sure that the e.Result.DetailedData is a collection like a List, Dictionary or an array. Sorry about the confusion.

              V.

              A Offline
              A Offline
              arkiboys
              wrote on last edited by
              #6

              Thank you

              V 1 Reply Last reply
              0
              • A arkiboys

                Thank you

                V Offline
                V Offline
                V 0
                wrote on last edited by
                #7

                So it worked then?

                V.

                A 1 Reply Last reply
                0
                • V V 0

                  So it worked then?

                  V.

                  A Offline
                  A Offline
                  arkiboys
                  wrote on last edited by
                  #8

                  yes, thank you

                  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