-1

this is the class:

public static List<MasterReject> GetData()
{
var context = new FingerScanContext();
return (from a in context.MasterRejects
select a).ToList();
}

this is how i called the grid view:

 InitializeComponent();
 List<MasterReject> mrj = new List<MasterReject>();
 gridView2.OptionsBehavior.Editable = false;
 mrj = MasterReject.GetData();
 gridView.DataSource = mrj;
 searchLookItem.Properties.DisplayMember = "ItemName";
 searchLookItem.Properties.ValueMember = "ItemID";
ivorish
  • 29
  • 2
  • 10
Modulus
  • 13
  • 4
  • You want to sort GridView Page? – SelvaS Mar 13 '15 at 06:56
  • i wish i can show you the screenshots but since im new i cant.. i only can post the code.. so there is a column named "Char" A11 A1 A2 but my gridview (after being sorted) become : A1 A11 A2 but i want to be sorted like this : A1 A2 A11 – Modulus Mar 13 '15 at 07:07
  • If I understand you correctly you need natural sorting [Here is the link to how to do that](http://www.interact-sw.co.uk/iangblog/2007/12/13/natural-sorting) – Mahesh Mar 13 '15 at 07:47

2 Answers2

0

If I am understanding your question then you could just simply do this:

public static List<MasterReject> GetDatas()
{
    var context = new FingerScanContext();
    // assuming that Id is the primary key and you want to sort on that
    return context.MasterRejects.OrderBy(m=> m.Id).ToList();
}
Syed Farjad Zia Zaidi
  • 3,302
  • 4
  • 27
  • 50
  • still showing the same results.. i wish i can show you the screenshots but since im new i cant.. i only can post the code.. so there is a column named "Char" A11 A1 A2 but my gridview (after being sorted) become : A1 A11 A2 but i want to be sorted like this : A1 A2 A11 – Modulus Mar 13 '15 at 07:13
  • You want to sort the columns? – Syed Farjad Zia Zaidi Mar 14 '15 at 03:42
0

Try this

public static List<MasterReject> GetDatas()
{
    var context = new FingerScanContext();

    return context.MasterRejects.OrderBy(m=>Regex.Split(m.Replace("
    ", ""), "([0-9]+)")
   ).ToList();
}
ivorish
  • 29
  • 2
  • 10