Need Datasource not firing !!

4 posts, 0 answers
  1. Waleed Seada
    Waleed Seada avatar
    241 posts
    Member since:
    May 2006

    Posted 31 Dec 2009 Link to this post

    Dear All,

    I can't get it to work ...
    I reviewed all the forums post regards the NeedDataSource event handlers all the concepts ....

    Here is my Issue:
    I create a contentpage that exactly matches the tab loadondemad example :

    But the grids on the loaded user-controls doesn't do any sorting or paging although I implement the OnNeedDatasource event which never fires at all (which cause the sorting or paging miss-behavior).

    This is my .ascx grid definition code snippet:
        <MasterTableView Width="100%"/>  
    The user-control scenario starts when it loaded and then filled with data using the DisplayValues method that receive a business object (summaryCredit[]) and bind it to the radgrid which I change later to use a datatable when I thought it was the problem.
    anyway here is the method:
    public void DisplayValues(SummaryCredit[] summaryCredit)  
        DataTable tdt = new DataTable();  
        foreach (var credit in summaryCredit)  
            tdt.Rows.Add(credit.DataFrom, credit.CatalogueCode, credit.Creditfacility);  
        SummaryCreditGrid.DataSource = tdt;  
        Session["SummaryCreditGrid"] = tdt;  

    and the NeedDataSource method:
    protected void SummaryCreditGrid_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e)  
        DataTable dt = new DataTable();  
        dt = Session["SummaryCreditGrid"as DataTable;  
        if (dt != null)  
            SummaryCreditGrid.DataSource = null;  
            SummaryCreditGrid.DataSource = dt;  
    I put a breakpoint in this method but it never fire !!

    What could be my problem ?

  2. Schlurk
    Schlurk avatar
    812 posts
    Member since:
    May 2009

    Posted 31 Dec 2009 Link to this post

    I believe the reason the NeedDataSource event is not firing is because you are applying data to the Grid in the DisplayValues method, which will cause the NeedDataSource event to not fire since the Grid does not need data.
  3. DevCraft R3 2016 release webinar banner
  4. Waleed Seada
    Waleed Seada avatar
    241 posts
    Member since:
    May 2006

    Posted 01 Jan 2010 Link to this post

    Hello Schlurk ,

    But it is true that I am binding the grid outside the need_datasource event. anyway the execution doesn't reach the breakpoint in the EventHandler "SummaryCreditGrid_NeedDataSource".

    Beside the fact that the grid should call that event when sorting or paging, right !

    I will try to remove every script only the EventHandler with the breakpoint and see what I will get.

    What is your opinion in such case !!

    Best regards
  5. Waleed Seada
    Waleed Seada avatar
    241 posts
    Member since:
    May 2006

    Posted 02 Jan 2010 Link to this post

    Hi Schlurk,

    I guess you are right !!

    It depends from the very beginning if you use need_datasource or not, I though the event could be used later on with the up coming interaction with the grid, I mean you can't MIX both ways.

    Thanks and best regards
Back to Top