0
页面
LINQ的结果我想表明我与LINQ到页面查询项目。显示
我似乎无法找到任何简单的例子!
我有我的查询,TOELINE是我的数据库名称
// Get the data context for the GROUP database
GroupDBDataContext db = new GroupDBDataContext();
// Query the database
var best_sellers = from bs in db.TOELINE
where bs.Company == "247HO001"
select bs;
我怎么那么我.aspx
页面中,遍历结果并插入,我想,我知道我可以输出使用GridView控件但是,我只想循环播放每条记录,并在任何地方显示不同的字段。
因此,像下面:
<div id="best_sellers">
<%
foreach (SingleRow in best_sellers)
{
// Show each row, the Company and ProductName fields
Response.Write("<div class=\"best_seller_row\">" + SingleRow["Company"] + " - " + SingleRow["ProductName"] + "</div>");
}
%>
</div>
我感到困惑,有没有这样一些简单的例子。用PHP看起来很容易。
感谢您的帮助。可悲的是我收到了这个错误:编译器错误消息:CS0021:不能用[]对'TOELINE'类型的表达式进行索引[ – Luke
@Coulton对不起 - 应该是句号。请参阅编辑。 – podiluska