Im trying to sortmy datagrid two ways and nothing happens, Originally I was sorting it once and sorting my dataview, this worked ok. Now I am trying to sort the datagrid directly and nothing happens.
VB Code:
Function pulldata() Dim strChnl As String = Trim(lstChnl.SelectedItem.Value) Dim dsOne As New System.data.DataSet da.Fill(dsOne, "dtOne") Dim dvOne As New DataView(dsOne.Tables("dtone")) dvOne.RowFilter = "CHNL_ID ='" & strChnl & "'" dgOne.DataSource = dvOne dgOne.DataBind() End Function Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load If Not Page.IsPostBack Then Dim cmdChnl As New System.Data.SqlClient.SqlCommand _ ("select top 500 chnl_id from olm_003_all group by chnl_id order by chnl_id", sqlOne) Dim drchnl As System.Data.SqlClient.SqlDataReader sqlOne.Open() drchnl = cmdChnl.ExecuteReader() lstChnl.DataSource = drchnl lstChnl.DataTextField = "chnl_ID" lstChnl.DataBind() drchnl.Close() sqlOne.Close() Else End If End Sub Private Sub lstChnl_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles lstChnl.SelectedIndexChanged pulldata() End Sub Private Sub dgOne_PageIndexChanged(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridPageChangedEventArgs) Handles dgOne.PageIndexChanged dgOne.CurrentPageIndex = e.NewPageIndex pulldata() End Sub Private Sub dgOne_SortCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridSortCommandEventArgs) Handles dgOne.SortCommand Dim curSortExpr As String = dgOne.Attributes("SortExpr") Dim newSortExpr As String = e.SortExpression If Not (curSortExpr Is Nothing) AndAlso curSortExpr.ToString = e.SortExpression Then newSortExpr &= " DESC" End If dgOne.Attributes("SortExpr") = newSortExpr pulldata() End Sub End Class




Reply With Quote