转换为列表类型 [英] Converting To List Type
本文介绍了转换为列表类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
转换为列表类型,下面的代码没有成功运行任何人都可以帮助我得到错误下面,我已经使用Linq To Sql Classes帮助修改了代码
ServiceReference1.ShopClient obj = new ServiceReference1.ShopClient();
列表< servicereference1.product> productlist = new List< servicereference1.product>();
ServiceReference1.Product product = obj.GetProduct(int.Parse(textBox1.Text));
dataGridView2.DataSource = productlist.Add(product);
解决方案
productlist.Add(product );
只需在列表中添加Product
,添加
方法就不会返回对象
。
也请看这里:
DataGridView.DataSource属性 [ ^ ]
如何:将对象绑定到Windows窗体DataGridView控件 [< a href =http://msdn.microsoft.com/en-us/library/y0wfd4yz%28v=vs.110%29.aspxtarget =_ blanktitle =New Window> ^ ]
Converting To List Type, The Below Code Was Not Running Successfully Any One Can Help Please I Was Getting Error Below, i have wriiten the code in service with help of Linq To Sql Classes
ServiceReference1.ShopClient obj = new ServiceReference1.ShopClient(); List<servicereference1.product> productlist = new List<servicereference1.product>(); ServiceReference1.Product product = obj.GetProduct(int.Parse(textBox1.Text)); dataGridView2.DataSource= productlist.Add(product);
解决方案
productlist.Add(product);
just adds aProduct
to the list, and theAdd
method doesn''t return anObject
.
Have also a look here:
DataGridView.DataSource Property[^]
How to: Bind Objects to Windows Forms DataGridView Controls[^]
这篇关于转换为列表类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文