PS:SQL 語法要先學會此帖才有懂哦!! 不然會 zzz..
在 ASP.NET 按下 SelectBtn 按鈕後利用 LINQ 寫法在 Models 中找到符合條件(sex 是 Man)
將它顯示在網頁上 (在 Browser 按右鍵選檢視網頁原始碼才看的到結果)
protected void SelectBtn_Click(object sender, EventArgs e)
{
var Models = new[]
{
new {name="SuperMan", sex="Man", height=200, weight=80},
new {name="SuperWoman", sex="Woman", height=170, weight=50},
new {name="SpiderMan", sex="Man", height=190, weight=72}
};
var females = from f in Models where f.sex == "Man" orderby f.name select new {f.name, f.height, f.weight};
foreach (var par in females)
{
Response.Write(par.name);
Response.Write(par.height);
Response.Write(par.weight);
}
}
在 ASP.NET 按下 SelectBtn 按鈕後利用 LINQ 寫法在 Models 中找到符合條件(sex 是 Man)
將它顯示在網頁上 (在 Browser 按右鍵選檢視網頁原始碼才看的到結果)
protected void SelectBtn_Click(object sender, EventArgs e)
{
var Models = new[]
{
new {name="SuperMan", sex="Man", height=200, weight=80},
new {name="SuperWoman", sex="Woman", height=170, weight=50},
new {name="SpiderMan", sex="Man", height=190, weight=72}
};
var females = from f in Models where f.sex == "Man" orderby f.name select new {f.name, f.height, f.weight};
foreach (var par in females)
{
Response.Write(par.name);
Response.Write(par.height);
Response.Write(par.weight);
}
}
留言
張貼留言