Question

I tried to consume a wcf data service reference I made earlier. everything was in order until I tried to load the data in a datagrid in the client, but it only load the column header. no data being loaded, although the database are filled with data.

there are no error was being thrown by visual studio.

Here are the codes and the screenshot on what's going on

namespace AccountingApplication.Views.Invoices
{
    public partial class InvoicePages : Page
    {
        InventoryEntities SalesOrderHeaderContext = new InventoryEntities(new Uri("http://localhost:9090/EntityDataServices/EntityDataServices.svc/"));
        DataServiceCollection<SalesOrderHeader> SalesOrderCollection = new DataServiceCollection<SalesOrderHeader>();

        public InvoicePages()
        {
            InitializeComponent();

            LoadSalesOrderHeader();
        }

        private void LoadSalesOrderHeader()
        {
            SalesOrderCollection.LoadCompleted += new EventHandler<LoadCompletedEventArgs>(SalesOrderCollection_loadCompleted);
            var soQuery = from salesOrder in SalesOrderHeaderContext.SalesOrderHeaders 
                          select salesOrder;
            SalesOrderCollection.LoadAsync(soQuery );
        }

        private void SalesOrderCollection_loadCompleted(object sender, LoadCompletedEventArgs e)
        {
            SalesOrderHeaderRadGridView.ItemsSource = SalesOrderCollection.ToList();
            testDG.ItemsSource = SalesOrderCollection;
        }
    }
}

enter image description here

Was it helpful?

Solution 3

ok apparently almost all tutorial on the internet use these lines as clientaccesspolicy.xml put in like this

<?xml version="1.0" encoding="utf-8"?>
<access-policy>
  <cross-domain-access>
    <policy>
      <allow-from http-request-headers="SOAPAction">
        <domain uri="*"/>
      </allow-from>
      <grant-to>
        <resource path="/" include-subpaths="true"/>
      </grant-to>
    </policy>
  </cross-domain-access>
</access-policy> 

this line cause a major issue on this line since silverlight 4

<allow-from http-request-headers="SOAPAction">

we have to change the http-request-headers="*"> in order to make the web service works.

OTHER TIPS

This is just an idea, but it seams you pick data from db in this line

var SOQuery = from salesOrder in SalesOrderHeaderContext.SalesOrderHeaders select salesOrder;

yet you do not put SOQuery anywhere. I just don't see what you do with selected data. You collected data, but you are not using it. SOQuery should be some kind of list now. Hope this helps any.

I've got the answer, but I will need to get some sleep first. I'll post the answer first thing in the morning

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top