> foreach(DataRow dr in d.Table.Rows)
This line is the problem. You are using a DataView to sort, yet you are accessing the underlying table directly.
In order to use the sorted data, you must query the table *through* the DataView you created:
DataView view = new DataView(state.getPlayers());
view.Sort = "Name";
foreach (DataRowView row in view)
// Notice how the view is enumerates "DataRowView" objects
{
dataMenu.Items.Add(new DataItem(row["Name"].ToString(), row["File"].ToString()));
}
--
Dave Sexton
dave@www..jwaonline..com
-----------------------------------------------------------------------
"Terry McNamee" <n/a> wrote in message news:uX**************@tk2msftngp13.phx.gbl...
DataView d = new DataView(state.getPlayers());
d.Sort = "Name ASC";
foreach(DataRow dr in d.Table.Rows)
{
dataMenu.Items.Add(new DataItem(dr["Name"].ToString(),dr["File"].ToString()));
}
Please could someone tell me why this isn't sorting the names in alphabetical order?
Many thanks