Here is my scenario:
I want to use the in memory Data ONLY for the sorting...NO requerying of the database.
On Page load event I use a DataSet to DataBind to the DataGrid.
Then when I sort I use a DataView to sort then try to bind to the DataGrid using the DataView but the Page load event is firing again. So, how do I do a simple sort?
Code:Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load If Not IsPostBack Then SqlDataAdapter1.SelectCommand.Parameters("@strDepartment").Value = "web" SqlDataAdapter1.Fill(Ds1) DataGrid1.DataBind() End If End Sub Private Sub DataGrid1_SortCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridSortCommandEventArgs) Handles DataGrid1.SortCommand Dim SortExpression As String = e.SortExpression.ToString() dv.Sort = SortExpression DataGrid1.DataSource = dv DataGrid1.DataBind() End Sub End Class




Reply With Quote