1
我遇到了一些麻烦,我认为,radSchedular。如何在更改绑定数据集后刷新radSchedule?
我有一个radSchedular我绑定到数据集。
我预计radSchedular时,我改变了数据集更新。但我不明白这一点。
我的问题是。数据集更新时如何更新radSchedular的显示?
示例代码:
我如何绑定: -
private void BindToDataSet()
{
//Map fields for Appointments
AppointmentMappingInfo appointmentMappingInfo = new AppointmentMappingInfo();
appointmentMappingInfo.Start = "appointments_Start";
appointmentMappingInfo.End = "appointments_End"; //LOTS OF THESE SO I CUT THE REST OUT OF THIS EXAMPLE
datasource.EventProvider.Mapping = appointmentMappingInfo;
datasource.EventProvider.DataSource = dsSchedule.Tables[0]; //MY DATASET IS GENERATED FROM AN XML FILE WITH A SCHEMA
//Bind
radScheduler1.DataSource = datasource;
}
我如何获得数据集改变事件: -
private void BindEvents(){
// RowChanged event handler.
dsSchedule.Tables[0].RowChanged += new DataRowChangeEventHandler(RowChanged);
// Add a RowDeleted event handler.
dsSchedule.Tables[0].RowDeleted += new DataRowChangeEventHandler(RowDeleted);}
事件方法: -
private void RowChanged(object sender, DataRowChangeEventArgs e){
StoreToXML();
BindEvents();}
我如何存储数据a第二,我想,刷新radSchedular: -
private void StoreToXML(){
//remove the dataset change deligates as we are about to change the Dataset and we don't want a loop
UnBindEvents();
foreach (DataRow rowAppointments in dsSchedule.Tables["Appointments"].Rows)
{
string currentResource = rowAppointments["appointments_ResourceID"].ToString();
foreach (DataRow rowResources in dsSchedule.Tables["Resources"].Rows)
{
if (rowResources["resources_ID"].ToString() == currentResource)
{
rowAppointments["appointments_Location"] = rowResources["resources_Name"]; //THIS IS WHY I WANT THE radSCHEDULAR TO UPDATE.
} //I WANT TO SEE THE RESOURCE IN THE LOCATION FIELD
}
}
StreamWriter myStreamWriter = new StreamWriter(@"E:\My .NET\Hardware_Scheduler_Application\stdData.xml");
dsSchedule.WriteXml(myStreamWriter, XmlWriteMode.WriteSchema);
myStreamWriter.Close();
BindToDataSet(); //I THOUGHT THAT THIS WOULD REFRESH THE radSCHEDULAR
//rebind the changed events
BindEvents()}
数据集是否暴露IObservable? –
不,我不认为DataSets可以。 – Richard210363