RadGrid.Rebind() does not show new datasource

10 posts, 0 answers
  1. Arnaud
    Arnaud avatar
    13 posts
    Member since:
    Sep 2013

    Posted 07 Aug 2014 Link to this post

    Hello

    I have a RadGrid that works well : it shows the rows in the dataSource and I can use the seeded buttons to add rows etc ...

    Now I want to some rows programmatically, so I modify the DataSource in the codeBehind then run RadGrid. Rebind() but it does not shows the new datasource rows.

    What could be the explanation for this ?

    Loko
  2. SANJAY
    SANJAY avatar
    61 posts
    Member since:
    Jun 2012

    Posted 07 Aug 2014 in reply to Arnaud Link to this post

    Hi Arnaud

    This works fine at my end

    Protected Sub RadGrid1_NeedDataSource(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridNeedDataSourceEventArgs) Handles RadGrid1.NeedDataSource
            Try
                Dim r As New Data.DataSet
                If IsNothing(Me.Session("ptls")) Then
                    'Code to Pouplate the recordset
                    Me.Session("ptls") = r
                Else
                    r = CType(Me.Session("ptls"), Data.DataSet)
                End If

                RadGrid1.DataSource = r
            Catch ex As Exception
              
            End Try

        End Sub

     Protected Sub btnadd_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnadd.Click
            Try
                 Dim r As New Data.DataSet
                    r = CType(Me.Session("ptls"), Data.DataSet)
                    'Code to Add the records in the data.dataset
                    Me.Session("ptls") = r
                    RadGrid1.Rebind()
            Catch ex As Exception
               
            End Try

        End Sub


    After the Ragrid1.Rebind() is called the _NeedDataSource function is called. It reads the dataset from session and gets the updated dataset which is used to populate the grid

    Hope this solves your query


    Regards


    Sanjay
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. SANJAY
    SANJAY avatar
    61 posts
    Member since:
    Jun 2012

    Posted 07 Aug 2014 in reply to Arnaud Link to this post

    Hi Arnaud

    Just in case you are using the Ajax to update the page kindly include the RadGrid in the Updatedcontrol list.

    Regards


    Sanjay
  5. Arnaud
    Arnaud avatar
    13 posts
    Member since:
    Sep 2013

    Posted 11 Aug 2014 in reply to SANJAY Link to this post

    Hi

    Sorry for the delay to answer.

    In my case too , the Rebind() makes Radgrid run the NeedDataSource code, the DataSource now contains the new rows but I can't see them on screen, looks like the Radgrid display is not refreshed or something like that.

    Please find my files here :
    http://wikisend.com/download/305932/PopupMarketing.aspx
    http://wikisend.com/download/819472/PopupMarketing.aspx.cs

    - grid is "RadGrid_Regroupements"
    - "RadButton_ArticleReference_Valid_Click" is run when you click on the first button, it grabs some data from DB then sets them in the TSession variable I use to keep data, then it runs sub-proc "SetModeleRegroupement" to do the Rebind().

    Regards
    Arnaud
  6. SANJAY
    SANJAY avatar
    61 posts
    Member since:
    Jun 2012

    Posted 11 Aug 2014 in reply to Arnaud Link to this post

    Hi Arnaud

    Your code seems to be correct.

    Please check on

    1) When the Needsource is called again if the TSuppression has all the new rows as well ( I am sure that you would have checked the same, just a gentle reminder)
    2) I guess you are sure that new column data has same name as in original as the grid is bound to.
    3) Set the id desc if you which to see the new rows on the top

    Just in case I have not been able to give you a solution, I feel sorry for the same


    Regards
  7. SANJAY
    SANJAY avatar
    61 posts
    Member since:
    Jun 2012

    Posted 12 Aug 2014 in reply to SANJAY Link to this post

    Hi Arnaud

    A word of caution

    the original recordset

    id, Value
    5, A
    4,B
    3, c
    2,d
    1, e


    Now you add 1 record so the recordset is

    5, A
    4,B
    3, c
    2,d
    1, e
    6, f


    the new record comes at the end of the recordset and not at the begining

    This is because the sorting of the session object doesnot occur by itself

    We donot search of the record at the end of the file and miss it

    If this is the problem then we could explicitly sort the record set and then bind to Grid


    Regards

  8. Arnaud
    Arnaud avatar
    13 posts
    Member since:
    Sep 2013

    Posted 12 Aug 2014 in reply to SANJAY Link to this post

    Hi Sanjay

    Thanks for the reminders. I really appreciate your time and tips.

    Finally I found out the issue : I had to remove the RadAjaxManager in my asp page and it works.

    Arnaud
  9. SANJAY
    SANJAY avatar
    61 posts
    Member since:
    Jun 2012

    Posted 12 Aug 2014 in reply to Arnaud Link to this post

    Hi


    Radajaxmanager comes in way if

    1) If you donot enumeratd Radgrid in list of Upldated Controls
    2) It also come in way if you asp:panel

    Thanks for the feed back


    Regards


    Sanjay
  10. Viktor Tachev
    Admin
    Viktor Tachev avatar
    1488 posts

    Posted 13 Aug 2014 Link to this post

    Hi Arnaud,

    I have inspected the provided code and noticed that both RadAjaxManager and RadAjaxPanel are used to Ajax-enable the same controls. This must not be done as when the controls are Ajax-ified multiple times they may not work as expected.

    As you have seen for yourself when only one of the Ajax-enabling controls is used, the functionality works as expected.

    Regards,
    Viktor Tachev
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  11. Arnaud
    Arnaud avatar
    13 posts
    Member since:
    Sep 2013

    Posted 13 Aug 2014 in reply to Viktor Tachev Link to this post

    Thanks you Sanjay and Viktor for your explanations.

    Regards
    Arnaud
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017