I have a Datatable with columns named foldername,documentname. Data as below:
FolderName DocumentName
Folder1 HR[D] Document
Folder1 ___----'
Folder1 Asp_example.pdf
Folder2 SD
Folder3 Heavy_weight
Folder3 Accesorial Services
How to alphabetically sort DocumentName based on FolderName in .Net Framework 2.0.
Solution we tried is below but takes too many time as it contains more than 1200000 records.
int counter=0;
while (counter < searchDT.Rows.Count){
string FolderName = Convert.ToString(searchDT.Rows[counter]["Folder Name"]);
string exp = "[Folder Name] like '" + FolderName + "'";
if (FolderName.Contains("%") || FolderName.Contains("_") || FolderName.Contains("[]") || FolderName.Contains("'"))
exp = "[Folder Name] like '" + EscapeLikeValue(FolderName) + "'";
string sortExpression = "[Document Name] ASC";
DataRow[] drfoldername = searchDT.Select(exp, sortExpression);
foreach (DataRow row in drfoldername)
drfoldernameDT.ImportRow(row);
counter += drfoldername.Length;
}