当我尝试这个
protected void Grid_ViewSorting(Object sender, GridViewSortEventArgs e)
{
DataGrid myGrid = (DataGrid) sender;
DataTable datatable =(DataTable) myGrid.DataSource;
DataView dataView = datatable.DefaultView;
if(e.SortDirection.ToString() == "ASC")
{
dataView.Sort = e.SortExpression + "DESC";
} else
{
dataView.Sort = e.SortExpression + "ASC";
}
}
我收到错误消息 invalidCastException Was Unhandled By userCode 无法将类型为“System.Web.UI.WebControls.GridView”的对象转换为类型“System.Web.UI.Web.Contro.DataGrid”。