0

I created sql procedure, which returns table from database, where records are in some, defined order. But, when I execute this procedure and using sqldatasource and show results in GridView, rows, aren't in the same order as it should be. I checked in SQL Management Studio, and sql procedure works fine. Here is code, how I execute procedure :

ds.SelectCommand = "EXEC MyProcedure";
TableGridView.DataSource = ds.Select(new DataSourceSelectArguments());
TableGridView.DataBind();

ds is SqlDataSource created using <asp:SqlDataSource .../>

1 Answer 1

1

I would make sure that my SQL in my procedure has an ORDER BY to ensure that it will always sort initially the way you want.

SELECT * FROM Products ORDER BY ProductName

If you are still seeing your data come up in the incorrect order in your GridView, try setting it to not allow sorting to see if the control is changing the order.

TableGridView.AllowSorting = False;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.