我想知道这是否可行,但这是公共的odata网络服务:http://services.odata.org/AdventureWorksV3/AdventureWorks.svc/
我想知道是否可以从此Web服务获取数据并将其绑定到数据网格视图。我能够使用以下代码将其输入文本框:
public void DisplayProduct(AdventureWorksService.vProductCatalog product)
{
richTextBox1.AppendText(Environment.NewLine + product.ProductName + " | " + product.ProductNumber + " | " + product.ProductCategory + Environment.NewLine);
}
public void ListAllProducts(AdventureWorksService.AdventureWorksEntities container)
{
foreach (var p in container.ProductCatalog)
{
DisplayProduct(p);
}
}
private void button1_Click(object sender, EventArgs e)
{
Uri uri = new Uri("http://services.odata.org/AdventureWorksV3/AdventureWorks.svc/");
var container = new AdventureWorksService.AdventureWorksEntities(uri);
container.SendingRequest2 += (s, a) =>
{
richTextBox1.AppendText(a.RequestMessage.Method + " " + a.RequestMessage.Url);
};
ListAllProducts(container);
}
我尝试将AdventureWorksService.vProductCatalog
产品合并到数据集,但这不起作用。