DataView.Sort Property

ashisthebest

New Member
Does anyone know the code which works on DataGrid sort?<BR>I used code from MSDN, but as a result happens nothing.:(<BR>I've tried as follows:<BR>Function CreateDataSource() As ICollection<BR> Dim dt As New DataTable()<BR> Dim dr As DataRow<BR> Dim Rand_Num As New Random()<BR> <BR> dt.Columns.Add(New DataColumn("IntegerValue", GetType(Int32)))<BR> dt.Columns.Add(New DataColumn("StringValue", GetType(String)))<BR> dt.Columns.Add(New DataColumn("CurrencyValue", GetType(Double)))<BR> <BR> Dim i As Integer<BR> For i = 0 To 14<BR> dr = dt.NewRow()<BR> <BR> dr(0) = i<BR> dr(1) = "Item " & i.ToString()<BR> dr(2) = 1.23 * Rand_Num.Next(1, 15)<BR> <BR> dt.Rows.Add(dr)<BR> Next i<BR> <BR> Dim dv As New DataView(dt)<BR> dv.Sort = SortExpression<BR> Return dv<BR> End Function 'CreateDataSource<BR><BR><BR>Sub Sort_Grid(sender As Object, e As DataGridSortCommandEventArgs)<BR> SortExpression = e.SortExpression.ToString()<BR> ItemsGrid.DataSource = CreateDataSource()<BR> ItemsGrid.DataBind()<BR>End Sub 'Sort_Grid<BR>
 
Back
Top