This is a migrated thread and some comments may be shown as answers.

RadGrid.Rebind() not firing NeedDataSource

9 Answers 2943 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jason Maronge
Top achievements
Rank 1
Jason Maronge asked on 11 Nov 2008, 04:13 PM
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

 

9 Answers, 1 is accepted

Sort by
0
Yavor
Telerik team
answered on 13 Nov 2008, 08:13 AM
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.
0
Mattias
Top achievements
Rank 1
answered on 30 Jan 2009, 09:38 AM
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.

1
Mattias
Top achievements
Rank 1
answered on 30 Jan 2009, 10:01 AM
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();  

0
Michelle
Top achievements
Rank 1
answered on 10 Jan 2013, 11:54 PM
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!
0
Aaron Abdis
Top achievements
Rank 1
answered on 08 Aug 2013, 08:15 PM
v.2012.3.1205.40, and i have the same issue, with the same solution.
Setting the DataSource = Nothing before calling Rebind() fixes it.
0
Al
Top achievements
Rank 1
Iron
Iron
Iron
answered on 16 Jul 2015, 12:56 PM
 I see the same issue in 2015 Q2 and the same fix solves the problem
0
Viktor Tachev
Telerik team
answered on 24 Jul 2015, 01:00 PM
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
0
Al
Top achievements
Rank 1
Iron
Iron
Iron
answered on 03 Aug 2015, 12:47 PM

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.

0
Maria Ilieva
Telerik team
answered on 04 Aug 2015, 02:51 PM
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
Tags
Grid
Asked by
Jason Maronge
Top achievements
Rank 1
Answers by
Yavor
Telerik team
Mattias
Top achievements
Rank 1
Michelle
Top achievements
Rank 1
Aaron Abdis
Top achievements
Rank 1
Al
Top achievements
Rank 1
Iron
Iron
Iron
Viktor Tachev
Telerik team
Maria Ilieva
Telerik team
Share this question
or