0

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!

1
Contributor
2
Replies
3
Views
6 Years
Discussion Span
Last Post by dawsonz
0

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; }
    }

Edited by dawsonz: n/a

0

I was infact wrong, that does not work unfortunately.

Any ideas?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.