Hi Stephanie,
Sorry, after looking at my code it was not applying a second time it was saving the report, this triggers the update happen..
Here's my code:
int GRsortIndex = 0;
int FLDsortIndex = 0;
IsRpt = false;
//SortDirection sd = rpt.DataDefinition.SortFields[1].SortDirection;
//rpt.DataDefinition.SortFields[1].SortDirection = SortDirection.NoSortOrder;
SortController sortController = rptClientDoc.DataDefController.SortController;
//sortController.Remove(GRsortIndex); // Sort of works for Groups - set the sort type to original order
//try
//{
// // you connot add a No sort, to remove the sort so you have no sort simply delete the sort and then save the report and reopen it. Only way to update the collection.
// //sortController.ModifySortDirection(GRsortIndex, CrSortDirectionEnum.crSortDirectionNoSortOrder);
//}
//catch
//{
// //btnSQLStatement.Text = "ERROR: " + ex.Message;
//}
foreach (CrystalDecisions.ReportAppServer.DataDefModel.Sort RASSortField in rptClientDoc.DataDefController.DataDefinition.Sorts)
{
foreach (SortField crSortField in rpt.DataDefinition.SortFields)
{
if (RASSortField.SortField.FormulaForm == crSortField.Field.FormulaName)
{
if (GRsortIndex >= 0)
{
if (crSortField.SortType.ToString() == CrystalDecisions.Shared.SortFieldType.GroupSortField.ToString())
{
textBox1 = "Group Sort:\n ";
// don not remove this is to alter sorts only
////SortController sortController = rptClientDoc.DataDefController.SortController;
////sortController.Remove(GRsortIndex); // Sort of works for Groups - set the sort type to original order
//try
//{
// // you connot add a No sort, to remove the sort so you have no sort simply delete the sort and then save the report and reopen it. Only way to update the collection.
// sortController.Remove(GRsortIndex); // Sort of works for Groups - set the sort type to original order
// //sortController.ModifySortDirection(GRsortIndex, CrSortDirectionEnum.crSortDirectionNoSortOrder);
// rptClientDoc.VerifyDatabase();
//}
//catch (Exception ex)
//{
// btnSQLStatement.Text = "ERROR: " + ex.Message;
//}
//////RASSortField.SortField.Name = @"DistinctCount (Employee_Options.EMPLOYEE Full Name, Employee_Options.EMPLOYEE Hire Date, 'Monthly')";
// do not remove this is to alter sorts only
IsRpt = false;
GRsortIndex++;
flcnt++;
}
else
{
textBox1 = "Record Sort:\n ";
}
.....
Code is commented out....
Don