Datagrid sorting in WebMatrix

I am using Web Matrix and had drag a datagrid to display the data based on the value entered in OrderID -TextField.

When user enter orderid in text box, the datagrid list out the selected item based on the OrderID..
But then I set the AllowSorting property for Datagrid... When display on the web, there is link on the datagrid header but it doesn't sort when I click that link on the header.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Depending on how you fill the datagrid, you need to handle the datagird sort event. A data source control can do it for you. But a DataTable would need to be sorted using a DataView, then rebound to the grid.
redcoderAuthor Commented:
I don't quite understand... Could you give simple example ?
How do you fill the DataGrid? That will allow me to provide a better example.
Otherwise you can look at:

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

redcoderAuthor Commented:
I am using the Select Data Method form the CODE panel in Web Matrix... Then choose the Table name and the Where condition... Finally select the DataSet and name the method as GetOrderDetails.

After that I bind the GetOrderDetails method with with :
Dim orderID as String
    orderID =TextBox2.Text
    DataGrid1.DataSource = GetOrderDetails(CInt(TextBox2.Text))

Then I set the property of Datagrid1 AllowSorting to TRUE

It is able to display the record but not able to sort when I click the link in the datagrid header
redcoderAuthor Commented:
I set the AutoGeneratedColumn to True..
Did you read the article I mentioned? It contains everything you need to sort. Be sure to read Part 2 of the article as it contains some of the info you need.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.