Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
115
Sorting the rows of web grid by a default column
posted

Hi,

This is a repost to a previous question I had.

I have a WebGrid that is populated by code from a text file.

There are four columns in the grid once setup from the text file - ID,START,END,FILENAME

I wish to have the grid sorted by Column 1 which is 'Start'.

How do I do this?

I have tried the following on the webgrid:-

Me.grdSchedule.Bands(0).Columns(1).SortIndicator = Infragistics.WebUI.UltraWebGrid.SortIndicator.Ascending
Me.grdSchedule.Bands(0).SortedColumns.Add(Me.grdSchedule.Columns(1), True)

 and it sorts the grid by column 1 fine, except the data underneath is not sorted.  How do i sort the data underneath to match what the grid is saying?

 Thanks.

Onan.

 

  • 485
    posted

    I have done the same thing and it working on my side.

    I have written these following code in InitializeLayout event :

    mobjCServerGrid.Bands[0].Columns.FromKey(mstrSortBy.Trim()).SortIndicator =  SortIndicator.Descending;

    mobjCServerGrid.Bands[0].SortedColumns.Add(mobjCServerGrid.Bands[0].Columns.FromKey(mstrSortBy.Trim()), true);

    Thanks.