May 14, 2014

Sorting in dataTable

//check to make sure our datatable has at
            //least one value. For this example it's not
            //really need but if we were taking the 
            //values from a database then this would be
            //very important!
            if (result.Rows.Count > 0)
                //convert DataTable to DataView
                DataView dv = result.DefaultView;
                //apply the sort on CustomerSurname column
                dv.Sort = "ProductID";
                //save our newly ordered results back into our datatable
                result = dv.ToTable();


Post a Comment

Nam Le © 2014 - Designed by, Distributed By Templatelib