0
Reply

Sort GridView from filtered dropdownlist

simplee

simplee

May 29 2009 5:37 AM
6.7k

I have this dropdownlist in my gridview. When i select the dropdownlist, it will populate the GridView. The Header in the gridview can be sorted in ASC order.

But wanted it to be select to sort with the filtered data from the dropdownlist. How can this be done ?

public void Sorting(object sender, GridViewSortEventArgs e)
        {
            DataTable dtHold = new DataTable();
            //dtHold = GetData().Tables[0];
            dtHold = ViewState["gv"] as DataTable;
            DataView dvHold = new DataView();
            dvHold = dtHold.DefaultView;

            GridViewSortExpression = e.SortExpression;

            dvHold.Sort = ViewState["SortExpression"] + " " + GetSortDirection();

            gv.DataSource = dvHold;
            gv.DataBind();
        }