Results 1 to 4 of 4

Thread: Sorting a DataGrid [RESOLVED]

Threaded View

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Nov 2003
    Location
    Chicagoland
    Posts
    92

    Resolved Sorting a DataGrid [RESOLVED]

    I'm new to ASP.NET, so this might be a very silly question.

    We have an application that spits out a text file in a tabular format. I'm working on an app that will grab that text file and display it in a datagrid that can be sorted. I got the reading in of the text file and the displaying in a datagrid done with no problems. I can't figure out how to sort it though.

    I can easily find how to do the sorting with Bound Columns - setting the 'SortExpression' property in the BoundColumn tag. But since I can't be positive on how many columns will be in the text file, I need to add the columns programmatically.

    VB Code:
    1. For Each ColumnName In ColumnNames
    2.      objDC = New DataColumn(ColumnName, GetType(String))
    3.      objDT.Columns.Add(objDC)
    4. Next

    But I can't find any way of setting the 'SortExpression' property this way, so when ever I click on a column header, it always errors out saying that it can't find the column name.

    How do I do this?
    Last edited by shadowfyre; May 3rd, 2005 at 10:02 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width