why does this grid not sort??

Discussion in 'ASP .Net' started by Daniel Bass, Dec 2, 2003.

  1. Daniel Bass

    Daniel Bass Guest

    I've got a data grid, with paging, and sorting allowed. I
    can find loads of examples, and have previous done this,
    when generating all the data from my database at run
    time, progmatically.

    Now I'm trying to do it through the design editor, using
    datasets instead of dataviews, etc...

    is what i'm doing below the wrong approach when
    attempting this in a "design time" fashion?
    why does it not work?

    ' ---------- CODE START

    ' other initialization and delcarations here...

    Private Sub Page_Load(ByVal sender As System.Object,
    ByVal e As System.EventArgs) Handles MyBase.Load

    If Not Page.IsPostBack Then
    ' Put user code here to initialize the data
    source
    sqldataadapterLogger.Fill(DataSetLogger)
    DataGrid1.DataSource =
    DataSetLogger.AvenueLog.DefaultView
    DataGrid1.DataBind()
    Session("dataset") = DataSetLogger
    Session("pageindex") = 0
    Session("sortcolumn") = Nothing
    End If

    End Sub

    Private Sub BindData()

    DataSetLogger = Session("dataset")
    Dim currentPageIndex As Integer = Session
    ("pageindex")
    Dim currentSortColumn As String = Session
    ("sortcolumn")
    Dim dv As DataView =
    DataSetLogger.AvenueLog.DefaultView

    ' apply sorting
    If (Not currentSortColumn Is Nothing) Then
    dv.Sort = currentSortColumn
    End If

    ' apply current page
    DataGrid1.CurrentPageIndex = currentPageIndex

    ' bind data
    DataGrid1.DataSource = dv
    DataGrid1.DataBind()


    End Sub

    Private Sub DataGrid1_PageIndexChanged(ByVal source
    As Object, ByVal e _
    As
    System.Web.UI.WebControls.DataGridPageChangedEventArgs) _
    Handles DataGrid1.PageIndexChanged

    Session("pageindex") = e.NewPageIndex
    BindData()

    End Sub


    Private Sub DataGrid1_SortCommand(ByVal source As
    Object, _
    ByVal e As
    System.Web.UI.WebControls.DataGridSortCommandEventArgs) _
    Handles DataGrid1.SortCommand

    Session("sortcolumn") = e.SortExpression
    BindData()

    End Sub

    ' ------------ CODE END

    Thanks for your time and help,
    in anticipation.
    Daniel.
    Daniel Bass, Dec 2, 2003
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Horace Nunley

    why why why does function not work

    Horace Nunley, Sep 27, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    455
    =?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=
    Sep 27, 2006
  2. Mr. SweatyFinger

    why why why why why

    Mr. SweatyFinger, Nov 28, 2006, in forum: ASP .Net
    Replies:
    4
    Views:
    874
    Mark Rae
    Dec 21, 2006
  3. Mr. SweatyFinger
    Replies:
    2
    Views:
    1,803
    Smokey Grindel
    Dec 2, 2006
  4. =?Utf-8?B?VmlkZHM=?=
    Replies:
    1
    Views:
    410
    =?Utf-8?B?SklHTkVTSA==?=
    Oct 9, 2007
  5. Navin
    Replies:
    1
    Views:
    684
    Ken Schaefer
    Sep 9, 2003
Loading...

Share This Page