RadGrid.Rebind() not firing NeedDataSource

10 posts, 0 answers
  1. Jason Maronge
    Jason Maronge avatar
    321 posts
    Member since:
    Jan 2005

    Posted 11 Nov 2008 Link to this post

    Does not seem like RadGrid.Rebind() is firing the NeedDataSource if NeedDataSource has already been executed on postback.  I am using a context menu on a grid row to duplicate the row but when I call the grid.Rebind() on the RadMenu_ItemClick it does not fire the NeedDataSource to rebind the grid. Has anyone else seen this?  I am using the Q3 2008.

    Thanks,

    Jason

     

  2. Yavor
    Admin
    Yavor avatar
    11 posts

    Posted 13 Nov 2008 Link to this post

    Hello Jason,

    I tested the setup which you mentioned, and the control behaved as expected.
    Attached to this message, you will find the code, which I used for testing.
    Take a look at it and let me know how it goes and if any other questions arise.

    Greetings,
    Yavor
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  3. Mattias
    Mattias avatar
    263 posts
    Member since:
    Aug 2012

    Posted 30 Jan 2009 Link to this post

    Hi,
    I have the same problem, rebind does not firing needdatasource.
    It's probably something simple I missed, can you see what?

     <asp:Panel ID="panelFilter" runat="server" CssClass="Filters" DefaultButton="buttonFilter"
        <table> 
            <tr> 
                <td> 
                    <asp:TextBox ID="textBoxFilterSearch" runat="server" CssClass="medium"></asp:TextBox> 
                </td> 
                <td> 
                    <asp:Button ID="buttonFilter" runat="server" Text="Sök" UseSubmitBehavior="true" OnClick="buttonFilterClick" /> 
                </td> 
            </tr> 
        </table> 
    </asp:Panel>  
     
    <asp:Panel ID="panelBusinessRegister" runat="server"
        <telerik:radgrid  
            ID="radGridBusinessRegister"  
            runat="server"  
            allowpaging="True"  
            allowsorting="True"  
            autogeneratecolumns="False"  
            gridlines="None"  
            onneeddatasource="radGridBusinessRegisterNeedDataSource"  
            Skin="SkyBlue"
            <HeaderContextMenu EnableTheming="True"
                <CollapseAnimation Duration="200" Type="OutQuint" /> 
            </HeaderContextMenu> 
            <MasterTableView> 
                <RowIndicatorColumn> 
                    <HeaderStyle Width="20px" /> 
                </RowIndicatorColumn> 
                <ExpandCollapseColumn> 
                    <HeaderStyle Width="20px" /> 
                </ExpandCollapseColumn> 
                <Columns> 
                    <telerik:GridBoundColumn UniqueName="Name" DataField="Name" HeaderText="Företag" /> 
                    <telerik:GridBoundColumn UniqueName="Phone1" DataField="Phone1" HeaderText="Telefon" /> 
                    <telerik:GridBoundColumn UniqueName="Email" DataField="Email" HeaderText="E-post" /> 
                </Columns> 
            </MasterTableView> 
            <FilterMenu EnableTheming="True"
                <CollapseAnimation Duration="200" Type="OutQuint" /> 
            </FilterMenu> 
        </telerik:radgrid> 
     
    </asp:Panel> 


        public partial class BusinessRegisterPage : System.Web.UI.UserControl 
        { 
            private BusinessRegisterCompanyService _companyService; 
            public BusinessRegisterCompanyService CompanyService 
            { 
                get { return _companyService; } 
                set { _companyService = value; } 
            } 
     
            public BusinessRegisterPage() 
            { 
                _companyService = new BusinessRegisterCompanyService(); 
            } 
     
     
            protected void Page_Load(object sender, EventArgs e) 
            { 
     
            } 
     
            protected void radGridBusinessRegisterNeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e) 
            { 
                Response.Write("Needed datasource, textbox value: " + textBoxFilterSearch.Text.Trim()); 
                radGridBusinessRegister.DataSource = CompanyService.GetCompanies(PageInfo.CurrentSite, true, textBoxFilterSearch.Text.Trim()); 
            } 
     
            protected void buttonFilterClick(object sender, EventArgs e) 
            { 
                Response.Write("Button clicked, textbox value: " + textBoxFilterSearch.Text.Trim()); 
                radGridBusinessRegister.Rebind(); 
            } 
        } 

    The needdatasource just runs on page load, not when clicking the button.

  4. Mattias
    Mattias avatar
    263 posts
    Member since:
    Aug 2012

    Posted 30 Jan 2009 Link to this post

    Hmm, it seems to work when setting datasource to null before rebind.
    I cant remember I had to do that before!? Well, well, now it works! :)
    protected void buttonFilterClick(object sender, EventArgs e)  
    {  
         radGridBusinessRegister.DataSource = null
         radGridBusinessRegister.Rebind();  

  5. Michelle
    Michelle avatar
    1 posts
    Member since:
    Aug 2011

    Posted 10 Jan 2013 Link to this post

    I had the same situation, calling Rebind() twice in a postback was not firing NeedDataSource for the second call.  This solution worked for me too (setting DataSource = null before second call to Rebind).  Thanks!
  6. Aaron Abdis
    Aaron Abdis avatar
    26 posts
    Member since:
    Mar 2005

    Posted 08 Aug 2013 Link to this post

    v.2012.3.1205.40, and i have the same issue, with the same solution.
    Setting the DataSource = Nothing before calling Rebind() fixes it.
  7. Al
    Al avatar
    221 posts
    Member since:
    Oct 2006

    Posted 16 Jul 2015 Link to this post

     I see the same issue in 2015 Q2 and the same fix solves the problem
  8. Viktor Tachev
    Admin
    Viktor Tachev avatar
    2251 posts

    Posted 24 Jul 2015 Link to this post

    Hello,

    Setting the DataSource property to null (Nothing) is required when the ViewState for RadGrid is disabled. Check out the following article that describes the approach in more detail:



    Regards,
    Viktor Tachev
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  9. Al
    Al avatar
    221 posts
    Member since:
    Oct 2006

    Posted 03 Aug 2015 in reply to Viktor Tachev Link to this post

    Hi Viktor,

    I am pretty sure that my ViewState is not disabled, mine is a standard grid and I did not set/change the ViewState setting.

  10. Maria Ilieva
    Admin
    Maria Ilieva avatar
    4017 posts

    Posted 04 Aug 2015 Link to this post

    Hi Al,

    Can you please share your RadGrid markup as well as the related code behind so that we can revise them locally and isolate the root cause of the issue?

    Regards,
    Maria Ilieva
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top