Refreshing a DataList

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Nathan Sokalski

    Refreshing a DataList

    I have a DataList control that I want users to be able to sort the data in
    by clicking 1 of 3 buttons. The function I have created to do this is as
    follows:


    Private Sub SortPoems(ByVal sortby As String)
    Dim ratedpoems As New DataTable
    Dim sqltext As String = "SELECT * FROM poemratings ORDER BY "

    Select Case sortby
    Case "title"
    sqltext &= "title"
    Case "rating"
    sqltext &= "(totalpoin ts/timesrated),tim esrated,title"
    Case "timesrated "
    sqltext &= "timesrated,(to talpoints/timesrated),tit le"
    End Select
    Dim dataadapterSele ct As New System.Data.Ole Db.OleDbDataAda pter(sqltext,
    System.Configur ation.Configura tionManager.App Settings("conne ctionstring"))
    dataadapterSele ct.Fill(ratedpo ems)
    Me.datRatings.D ataSource = ratedpoems
    Me.datRatings.D ataBind()
    End Sub


    When the page first loads, I call

    Me.SortPoems("t itle")

    from Page_Load, which works fine, but when I try to call it a second time
    using one of the buttons it does not work. However, if I call it twice in
    Page_Load, it does work when I call it with the buttons. Why is this? What
    is it that calling it a second time in Page_Load does that allows me to call
    it with the buttons? I am using Microsoft Access as my database, and I am
    using ASP.NET 2.0. Thanks.
    --
    Nathan Sokalski
    njsokalski@hotm ail.com
    有声小说网为广大读者提供热门小说在线免费阅读,本站收集的网络文学小说情节跌宕起伏,有声小说网是值得书友们收藏的小说在线阅读网。



  • Goofy

    #2
    Re: Refreshing a DataList


    1.) When you say you cannot call it from one of the buttons, do you mean

    a.) That the code is not executed
    b) That the code is executed but does not work as expected.?

    2.) If 1a) Then you need to look at the handler for the button , if 1b)
    then you need to review if the DataList is being bound somehere else in you
    code .


    3.) The order the events fire in are important, look at your event handlers
    for the page events and make sure you are not rebinding the control to
    another or an unpopulated data source.


    HTH






    "Nathan Sokalski" <njsokalski@hot mail.comwrote in message
    news:%235sOl6uL HHA.2456@TK2MSF TNGP06.phx.gbl. ..
    >I have a DataList control that I want users to be able to sort the data in
    >by clicking 1 of 3 buttons. The function I have created to do this is as
    >follows:
    >
    >
    Private Sub SortPoems(ByVal sortby As String)
    Dim ratedpoems As New DataTable
    Dim sqltext As String = "SELECT * FROM poemratings ORDER BY "
    >
    Select Case sortby
    Case "title"
    sqltext &= "title"
    Case "rating"
    sqltext &= "(totalpoin ts/timesrated),tim esrated,title"
    Case "timesrated "
    sqltext &= "timesrated,(to talpoints/timesrated),tit le"
    End Select
    Dim dataadapterSele ct As New
    System.Data.Ole Db.OleDbDataAda pter(sqltext,
    System.Configur ation.Configura tionManager.App Settings("conne ctionstring"))
    dataadapterSele ct.Fill(ratedpo ems)
    Me.datRatings.D ataSource = ratedpoems
    Me.datRatings.D ataBind()
    End Sub
    >
    >
    When the page first loads, I call
    >
    Me.SortPoems("t itle")
    >
    from Page_Load, which works fine, but when I try to call it a second time
    using one of the buttons it does not work. However, if I call it twice in
    Page_Load, it does work when I call it with the buttons. Why is this? What
    is it that calling it a second time in Page_Load does that allows me to
    call it with the buttons? I am using Microsoft Access as my database, and
    I am using ASP.NET 2.0. Thanks.
    --
    Nathan Sokalski
    njsokalski@hotm ail.com
    有声小说网为广大读者提供热门小说在线免费阅读,本站收集的网络文学小说情节跌宕起伏,有声小说网是值得书友们收藏的小说在线阅读网。

    >

    Comment

    Working...