为什么dataTable.DefaultView.Sort不起作用?
程序如下:
//dtServerBOList是dataTable object
dtServerBOList.DefaultView.Sort = "ServerName";
for (int i = 0; i < dtServerBOList.Rows.Count; i++)
{
DataRow dr = dtServerBOList.Rows[i];
Console.WriteLine (dr["ServerName"].ToString());
}
为什么dataTable.DefaultView.Sort不起作用?
打印出来的依然是无序的???
谢谢!
------解决方案--------------------
C# code
dtServerBOList.DefaultView.Sort = "ServerName";
for (int i = 0; i < dtServerBOList.DefaultView.Count; i++)
{
DataRowVew drv = dtServerBOList.DefaultView.Item[i]
Console.WriteLine (drv["ServerName"].ToString());
}