Answers

Question and Answer:

  Home  ASP.NET 2.0

⟩ How do we Sort the data from a Dataset?

Sorting is similar to filtering, in that you specify a sort expression. A typical sort expression is simply the name of the column to sort by. For example, to sort by the OrderDate column, you specify the sort expression OrderDate. However, you can sort by the value of any expression, including calculated values. If you call a table's Select method, you pass the sort expression as a parameter. If you are using data views, you specify the sort expression as the value of the view's "Sort" property.EX:' Visual BasicDim filterExp As String = "Status = 'Active'"Dim sortExp As String = "City"Dim drarray() As DataRowDim i As Integerdrarray = dataSet1.Customers.Select(filterExp, sortExp, DataViewRowState.CurrentRows)For i = 0 To (drarray.Length - 1) listBox1.Items.Add( drarray(i)("City").ToString )Next// C#string filterExp = "Status = 'Active'";string sortExp = "City";DataRow[] drarray;drarray = dataSet1.Customers.Select(filterExp, sortExp, DataViewRowState.CurrentRows);for (int i=0; i < drarray.Length; i++){ listBox1.Items.Add(drarray[i]["City"].ToString());}

 128 views

More Questions for you: