Large Text Sorting Problem
I have a DG that has a very large text field. I want the user to be able to sort by this field. If I hardcode a this
ORDER BY CAST(Q_Text As varchar(1000))
It works fine. So I am trying to force the variable to read that same way.
Here is my sorting code.
void DataGrid_Sort(object sender, DataGridSortCommandEventArgs e)
{
DG1.CurrentPageIndex = 0;
SortField = e.SortExpression;
if (e.SortExpression == "Q_Text")
{
lbl.Text = "Yes";
SortField = "Cast(Q_Text As varchar(1000))";
}
BindGrid();
}
protected String SortField {
get {
object o = ViewState["SortField"];
return (o == null) ? String.Empty : (String)o;
}
set {
ViewState["SortField"] = value;
}
}
And here is the SQL Statement:
CommandText = "SELECT Q_Section As Section, Q_Text As Questions, Rating, Response FROM smileReportView WHERE ((H_CrsTitle = '"+ddlCourseList.SelectedItem.Value+"') and (Set_Name = '"+ddlSetList.SelectedItem.Value+"') and (Held_Key = '"+ddlHeldList.SelectedItem.Value+"') and (Rating = '"+ddlRatingList.SelectedItem.Text+"')) ORDER BY " + SortField;
|