telerik RadGantt Binding from Code behind

15 posts, 0 answers
  1. jahangeer
    jahangeer avatar
    2 posts
    Member since:
    Sep 2014

    Posted 16 Sep 2014 Link to this post

    I want to bind Rad Gantt of Telerik from code behind here is my code:
    <telerik:RadGantt runat="server" ID="RadGantt1" Width="1275px" Height="600px" ListWidth="351px"
    SelectedView="WeekView" Skin="Silk" AutoGenerateColumns="false">
    <Columns>
    <telerik:GanttBoundColumn DataField="TaskName" DataType="String" Width="120px"></telerik:GanttBoundColumn>
    <telerik:GanttBoundColumn DataField="StartDate" DataType="DateTime" DataFormatString="dd/MM/yy" Width="40px"></telerik:GanttBoundColumn>
    <telerik:GanttBoundColumn DataField="EndDate" DataType="DateTime" DataFormatString="dd/MM/yy" Width="40px"></telerik:GanttBoundColumn>
    </Columns>
    <DataBindings>
    <TasksDataBindings IdField="TaskID" ParentIdField="TaskID" StartField="StartDate" OrderIdField="TaskID" SummaryField="Summary" ExpandedField="Expanded" EndField="EndDate" TitleField="TaskName"
    PercentCompleteField="PercentComplete" />
    <DependenciesDataBindings TypeField="Type" IdField="TaskID" PredecessorIdField="TaskID" SuccessorIdField="TaskID" />
    </DataBindings>
    </telerik:RadGantt>
    and in code behindRadGantt1.DataSource = Gatdata();
    RadGantt1.DataBind();I am having this error on DataBind() "DataSourceID may not be null in case of DataSource binding" here GetData() method return very simple datatable which contains columns and valid data
  2. Bozhidar
    Admin
    Bozhidar avatar
    1102 posts

    Posted 17 Sep 2014 Link to this post

    Hi,

    This functionality was not available in the Beta release of the control. You can however download the latest internal build and it should work.

    Regards,
    Bozhidar
    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.

     
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Felix
    Felix avatar
    42 posts
    Member since:
    Sep 2014

    Posted 19 Sep 2014 in reply to Bozhidar Link to this post

    Hi,

    I just downloaded the latest internal build (Telerik_UI_for_ASP.NET_AJAX_2014_2_916_Dev_hotfix) and got several problems with my XMLGanttProvider that I've used so far, if I want to insert, update or delete tasks. Did you change the xml-structure? But thats another topic.
    So I've tried to bind the RadGantt from code behind, which works perfectly. But if i try to e.g. update a task inside "OnTaskUpdate" - event, I get the same error: "DataSourceID may not be null in case of DataSource binding". What is the benefit of binding the RadGantt from Code behind when I get the same Error as before if I want to update my tasks...

    Regards,
    Felix
  5. Bozhidar
    Admin
    Bozhidar avatar
    1102 posts

    Posted 19 Sep 2014 Link to this post

    Hi Felix,

    I've attached a fully runnable example of a Gantt bound using the DataSource property from code behind, and with all the CRUD operations implemented through the Server events. Could you confirm if the sample is working on your end?

    As for the XML provider issues, could you open a support ticket and share a sample project, so that we can investigate the issues in detail?

    Regards,
    Bozhidar
    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.

     
  6. Felix
    Felix avatar
    42 posts
    Member since:
    Sep 2014

    Posted 22 Sep 2014 in reply to Bozhidar Link to this post

    Hi Bozhidar,

    I looked at your sample project and found the problem. I didn't know that I have to set the Datasoure-property on every postback. Since I have set it on every postback, everything looks fine. Thank you.

    Regards,
    Felix
  7. Sam
    Sam avatar
    60 posts
    Member since:
    Mar 2011

    Posted 29 Oct 2014 Link to this post

    Bozhidar, I am having an issue with the RadGantt. When I attach a OnTaskDelete event, the confirmation for the delete appears and the form is automatically submitted. Is this a bug in the control? It doesn't happen when I declare the datasource. This only happens when I try and bind the control in the code behind. 
  8. Bozhidar
    Admin
    Bozhidar avatar
    1102 posts

    Posted 30 Oct 2014 Link to this post

    Hello,

    I confirm that this is a bug, which we've already addressed and will be fixed in the next internal build. In the meantime to prevent the erroneous behavior you can just set DisplayDeleteConfirmation="false" to prevent the dialog from opening.

    Regards,
    Bozhidar
    Telerik
  9. Sam
    Sam avatar
    60 posts
    Member since:
    Mar 2011

    Posted 30 Oct 2014 in reply to Bozhidar Link to this post

    Ok, not a problem. Will do that. So that means I should probably have a separate save button in order to do one save. Kind of unrelated, but is there an easy way to add a button to the toolbar? Currently I'm using jquery to do so but was just curious if there was a way to add it without doing it client side. 
  10. Sam
    Sam avatar
    60 posts
    Member since:
    Mar 2011

    Posted 30 Oct 2014 in reply to Sam Link to this post

    One other question if you don't mind, when I add a task none of the form variables retain their value nor is the viewstate is available. Is this by design? What if you need to pass additional data set on the form to the insert event?

  11. Sam
    Sam avatar
    60 posts
    Member since:
    Mar 2011

    Posted 30 Oct 2014 Link to this post

    Bozhidar, I decided to stay with the declarative binding of the gantt. However, there is another issue with the gantt chart. If you have a parameter in the select statement or even a hard-coded WHERE clause, the gantt never comes back after an add. I get the JS error Uncaught TypeError: Cannot read property 'Start' of null. The record is added to the database but the gantt just sits there in wait mode. 
  12. Bozhidar
    Admin
    Bozhidar avatar
    1102 posts

    Posted 31 Oct 2014 Link to this post

    Hi ,

    When you insert a task into the database, the Gantt expects the same task to be immediately returned by the datasource, so that it can have the new ID, that the datasource has assigned to it. Perhaps your WHERE clause excludes the newly entered task and it can't be found after the insert statement, which causes the gantt to hang.

    Unfortunately this is hard to troubleshoot without some kind of sample to work on and debug. Would it be possible for you to send us a simplified sample that demonstrates the issue.

    Regards,
    Bozhidar
    Telerik
  13. Sam
    Sam avatar
    60 posts
    Member since:
    Mar 2011

    Posted 31 Oct 2014 in reply to Bozhidar Link to this post

    Oh I see. Yes, the filter was preventing the record from coming back. The issue is that I am populating a field on the form. That field is used in the code behind to filter the results for the gantt. However, the field is blank when a new task is added. I'm assuming the gantt uses it's own ajax and does not go through the ajaxmanager. I tried adding the field as an attribute to the gantt but that value didn't hold up on the gantt postback either. Is there a way to pass values back to the server from a gantt postback? 
  14. Bozhidar
    Admin
    Bozhidar avatar
    1102 posts

    Posted 03 Nov 2014 Link to this post

    Hello,

    With the recently released official version of the Gantt control (Q3 2014), when you use server events a full postback is triggered, which will transfer all the ViewState of all controls on the page. If you don't have an event attached, a simple callback is performed on each operation, which doesn't update the other controls on the page. So in your case you just have to handle the server OnTaskInsert event (and any other event for operations where you wish to trigger a full postback).

    Regards,
    Bozhidar
    Telerik
  15. Jahangeer
    Jahangeer avatar
    19 posts
    Member since:
    Apr 2013

    Posted 24 Jun 2015 Link to this post

    I have implemented your entire code but same error of "DataSourceID may not be null in case of DataSource binding" what to do now??
  16. Bozhidar
    Admin
    Bozhidar avatar
    1102 posts

    Posted 24 Jun 2015 Link to this post

    Hi,

    What is your version of the controls? If you run the attached page from a few answers back with the latest version of the controls, it should be working.

    Regards,
    Bozhidar
    Telerik
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017