This is a migrated thread and some comments may be shown as answers.

Sorting from a drowdown list

1 Answer 40 Views
Grid
This is a migrated thread and some comments may be shown as answers.
SonicImaging
Top achievements
Rank 1
SonicImaging asked on 29 Jan 2009, 02:34 PM
Hi,  I have a grid and in the page load I create a default sort express when !ispostback - that works

            GridSortExpression expression1 = new GridSortExpression();
            expression1.FieldName = "description";
            expression1.SortOrder = GridSortOrder.Ascending;
            productsViewRG1.MasterTableView.SortExpressions.AddSortExpression(expression1);

I also have a dropdown list above the grid during OnSelectedIndexChanged for the dropdown I want to change the sort order based on the users selection.

    protected void sortDDL1_OnSelectedIndexChanged(object sender, EventArgs e)
    {
        GridSortExpression expression1 = new GridSortExpression();
        expression1.FieldName = sortDDL1.Text;
        expression1.SortOrder = GridSortOrder.Ascending;
        productsViewRG1.MasterTableView.SortExpressions.AddSortExpression(expression1);

        productsViewRG1.Rebind();
    }

if I don't set the default search expression in the page load then setting the sort expression works from the drop down list,  but it doesn't allow me to set a default sort expression when the page is loaded.

Am I missing something

Thanks
-Keith

1 Answer, 1 is accepted

Sort by
0
SonicImaging
Top achievements
Rank 1
answered on 29 Jan 2009, 04:20 PM
yup I missed clearing the sort expressions in my OnSelectedIndexChanged since im only allowing one column to sort.

productsViewRG1.MasterTableView.SortExpressions.Clear();

works great now

-Keith



Tags
Grid
Asked by
SonicImaging
Top achievements
Rank 1
Answers by
SonicImaging
Top achievements
Rank 1
Share this question
or