I'm using DAL, and having trouble figuring out how to sort the returned data table. The case is throwing an error and intellisense isn't offering me much help:
// 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 />";
}
Error without the cast is:
Error 3 Cannot implicitly convert type 'System.Data.DataTable' to 'Artwork.tblSpecificationsDataTable'. An explicit conversion exists (are you missing a cast?)
Edit
Apparently I should be sorting in the query which is fine, but I want the option to ORDER BY any of the dozen fields without having to create a dozen queries in the table adapter, how do I go about doing this?