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