我正在使用DAL,並無法弄清如何對返回的數據表進行排序。此案引發錯誤和智能是不是我提供太多的幫助:ASP.net c#排序數據表
// Get all the specifications available to this user
Artwork.tblSpecificationsDataTable dsCommon = new Artwork.tblSpecificationsDataTable();
using (tblSpecificationsTableAdapter specAdapter = new tblSpecificationsTableAdapter())
{
specAdapter.FillByClientID(dsCommon, Master.loginData.loggedInUser.company.ID);
}
DataView v = dsCommon.DefaultView;
v.Sort = "category DESC";
dsCommon = (Artwork.tblSpecificationsDataTable)v.ToTable();
for (int i = 0; i < dsCommon.Count; i++)
{
test.Text += dsCommon[i].category + " " + dsCommon[i].FlatSize + "<br />";
}
錯誤,而不投是:
錯誤3無法隱式轉換類型 「System.Data.DataTable」來 'Artwork.tblSpecificationsDataTable'。 的顯式轉換存在(你 缺少強制轉換?)
編輯
顯然我應該在這是很好的查詢中的排序,但我想爲了通過任何的選擇無需在表格適配器中創建十幾個查詢,我該如何去做這件事?
你爲什麼不在數據庫中排序? – 2011-01-28 13:42:36
我有一個表格適配器,用於讀取行,我想以不同的方式返回行,還有許多排序方法,但不必爲每一行都分別進行查詢。這是錯誤的方式去做? – 2011-01-28 13:43:36