How to sort a datatable in dataset schema
<p>I am trying to sort a datatable into a Dataset.
In this dataset, I have 2 tables with relationship</p>

<blockquote>
  <p>Table 1 - Aluno (student)<br>
  Table 2 - Curso (course)</p>
</blockquote>

<p>The table aluno have a primary key 'CPF'. But I want to sort by NAME (NOME), but the sort sub doesn't work for the parent table ALUNO by NOME.</p>

<p>The result remains unsorted. I do not want to use a dataview as I must order by NAME the Table Student, this table is into a dataset schema.</p>

<p>Here is my code snippet:</p>

<pre><code>        if (dtGrdAlunos.HitTest(new Point(e.X, e.Y)).Row == -1 &amp;&amp; dtGrdAlunos.DataSource != null)
        {

            if (sSortType == string.Empty &amp;&amp; sColumnToSort == string.Empty)
                sSortType = " ASC";
            else if (sColumnToSort == dtTblAluno.Columns[dtGrdAlunos.HitTest(new Point(e.X, e.Y)).Column].ColumnName.ToString())
                sSortType = (sSortType == " DESC" ? " ASC" : " DESC");
            else if (sColumnToSort != dtTblAluno.Columns[dtGrdAlunos.HitTest(new Point(e.X, e.Y)).Column].ColumnName.ToString())
                sSortType = " ASC";

            sColumnToSort = dtTblAluno.Columns[dtGrdAlunos.HitTest(new Point(e.X, e.Y)).Column].ColumnName.ToString();
            rcTxtLeiaute.Text = sColumnToSort + " " + sSortType;

            dtGrdAlunos.DataSource = null;

            dsDataSet.Tables["Aluno"].DefaultView.Sort = sColumnToSort + sSortType;
            dsDataSet.Tables["Aluno"].AcceptChanges();
            dsDataSet.AcceptChanges();

            dtGrdAlunos.DataSource = dsDataSet.Tables["Aluno"];

            /*
            Application.DoEvents();
            for (int j = 0; j &lt; dsDataSet.Tables["Aluno"].Rows.Count; j++)
            {
                rcTxtLeiaute.Text += j.ToString() + " - " + dsDataSet.Tables["Aluno"].Rows[j]["NOME"].ToString() + "\r";
            }
            */
        }
</code></pre>