Hello

I'm currently using GridView.Sort("Column", ASC")

It works perfectly and sorts my gridview, however once I get to 10 or higher the sort order stops working and it goes. 1,10,2,3,4,5,6,7,9.

Here is my code would anyone care to explain why it does this?

DataSet ds = new DataSet();
        ds.ReadXml(Server.MapPath(@"xml\" + Request["Gradebook"] + ".xml"));
        foreach (DataColumn dc in ds.Tables[0].Columns)
        {
            dc.ColumnMapping = MappingType.Attribute;
        }

        //Dataview customised so that it can sort by, 'SortOrder' column.
         System.Data.DataView dv = new System.Data.DataView(ds.Tables[0]);
         dv.Sort = "SortOrder ASC";

        gv.DataSource = dv;
        gv.DataBind();

SortOrder is just a number from 1-100.

Thank you!

I have now sorted this issue out.

Code below:

void binddata()
    {
        DataSet ds = new DataSet();
        ds.ReadXml(Server.MapPath(@"xml\" + Request["Gradebook"] + ".xml"));
        foreach (DataColumn dc in ds.Tables[0].Columns)
        {
            dc.ColumnMapping = MappingType.Attribute;
        }

        //Dataview customised so that it can sort by, 'SortOrder' column.
        System.Data.DataView dv = new System.Data.DataView(ds.Tables[0]);
        // dv.Sort = string.Format("SortOrder ASC");
        dv.Sort = GridViewSortExpression;
}

    private string GridViewSortExpression
    {
        get { return ViewState["SortOrder"] as string ?? string.Empty; }

        set { ViewState["SortOrder"] = value; }
    }

I was infact wrong, that does not work unfortunately.

Any ideas?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.