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

How to Update an XML File from a RadSchedular

1 Answer 60 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Vuyiswa
Top achievements
Rank 2
Vuyiswa asked on 20 Jul 2010, 12:48 PM
Good Day

i am using a RaSchedular(Telerik) and i have an XML File on my solution and i bind my Schedular like this


 
   <pre> private void Bind_Viewer_For(String Module)
    {

    
            string strExpr = "Code like '%" + Module + "%'";
            XmlDataDocument xmlDatadoc = new XmlDataDocument();
            xmlDatadoc.DataSet.ReadXml(@"C:\Pilot Project\App_Data\TimeTable.xml");
            RadScheduler1.DataStartField = "STARTDATE";
            RadScheduler1.DataSubjectField = "DESCRIPTION";
            RadScheduler1.DataEndField = "ENDDATE";
            RadScheduler1.DataKeyField = "ID";

            dsfinal = xmlDatadoc.DataSet;

            if (dsfinal.Tables[0].Rows.Count &gt; 0)
            {
                DataView dv = dsfinal.Tables[0].DefaultView;
                dv.RowFilter = strExpr;
                RadScheduler1.DataSource = dv;
                RadScheduler1.DataBind();
                RadScheduler1.SelectedView = SchedulerViewType.MonthView;
                RadScheduler1.SelectedDate = Convert.ToDateTime(dv.Table.Rows[30]["ENDDATE"]);

            }
     

    }
</pre>

 

dsfinal is declared Globally. i am filtering my data as you can see in the expression and bind the control with the Detail view.  Now , my problem is when the updates are made. In the Schedular when updates are made , or when an appointment is moved
i need to Update the Dataset with the changes made. The Demo here  Explains a simple xml binding, but i am binding the Schedular with a Dataset and when changes i made, i want to save the changes in the dataset.

Now i have a save button that is supposed to take the changes made in the dataset and merge it back to the xml and my code looks like this

 protected void btnCommitChanges_Click(object sender, EventArgs e)
    {

            XmlDataDocument xmlDatadoc = new XmlDataDocument();
            xmlDatadoc.DataSet.ReadXml(@"C:\Pilot Project\App_Data\TimeTable.xml");

            DataSet dslist = new DataSet();
            dslist = xmlDatadoc.DataSet;

            dsfinal.Merge(dslist);
            dsfinal.WriteXml(@"C:\Pilot Project\App_Data\TimeTable.xml");

    }
 

 as you can see , i am taking the xml that is currently on the file system and i am loading it to a dataset and merge the two dataset. My question here is that is it going to updates the changes or it will override or insert new elements as if i am adding a new record on the xml ?

Again, after refresh the page, i could see the changes were not saved and the xml have not changed from the changes that were made in the dataset.

Thanks

1 Answer, 1 is accepted

Sort by
0
Peter
Telerik team
answered on 23 Jul 2010, 01:27 PM
Hi Vuyiswa,

You should update your data source on AppointmentUpdate/Insert/Delete, similarly to the approach from this demo.

Best wishes,
Peter
the Telerik team
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 Public Issue Tracking system and vote to affect the priority of the items
Tags
Scheduler
Asked by
Vuyiswa
Top achievements
Rank 2
Answers by
Peter
Telerik team
Share this question
or