Use it like this:
if (sortExpression != null && sortExpression.Length > 0)
table.DefaultView.Sort = sortExpression + " " + sortOrder;
}
If you would like to sort data in a control you could do it like this:
if (this.DataSource is DataTable) {
DataTable table = (DataTable)this.DataSource;
if (sortExpression != null && sortExpression.Length > 0) {
table.DefaultView.Sort = sortExpression + " " + sortOrder;
}
}
