Datagrid sorting in WebMatrix

Posted on 2006-03-29
Last Modified: 2012-06-21
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.
Question by:redcoder
    LVL 8

    Assisted Solution

    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.

    Author Comment

    I don't quite understand... Could you give simple example ?
    LVL 8

    Accepted Solution

    How do you fill the DataGrid? That will allow me to provide a better example.
    Otherwise you can look at:

    Author Comment

    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

    Author Comment

    I set the AutoGeneratedColumn to True..
    LVL 8

    Expert Comment

    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.

    Featured Post

    How to improve team productivity

    Quip adds documents, spreadsheets, and tasklists to your Slack experience
    - Elevate ideas to Quip docs
    - Share Quip docs in Slack
    - Get notified of changes to your docs
    - Available on iOS/Android/Desktop/Web
    - Online/Offline

    Join & Write a Comment

    ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
    Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
    This video is in connection to the article "The case of a missing mobile phone (". It will help one to understand clearly the steps to track a lost android phone.
    Sending a Secure fax is easy with eFax Corporate ( First, Just open a new email message.  In the To field, type your recipient's fax number You can even send a secure international fax — just include t…

    730 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now