I have bound my appointments to a dataset and have specified a data member (table name). Everything is displaying properly. I need to get able to retrieve an appointment and I'm trying to use the GetAppointmentFromBindingListObject function. I am passing in a DataRowView that maps to one of the datarows in my bound dataset, but it never returns anything. Any help on what I could be doing wrong?
Hello Richard,
The reason GetAppointmentFromBindingListObject isn't working with DataTable is that you are passing the dataRow object instead of DataRowView object.
If you want to use DataTables, you should cast your DataRow to DataRowView. I made quick test using the code below:
DataTable dt = new DataTable();
dt.Columns.Add("A", typeof(Appointment));
dt.Rows.Add(new Appointment(DateTime.Now, DateTime.Now.AddDays(2)));
dt.Rows.Add(new Appointment(DateTime.Now, DateTime.Now.AddDays(5)));
ultraCalendarInfo1.DataBindingsForAppointments.DataSource = dt;
DataRow dr = dt.Rows[0];
DataRowView drv = dt.DefaultView[dt.Rows.IndexOf(dr)];
Appointment app = ultraCalendarInfo1.Appointments.GetAppointmentFromBindingListObject(drv) as Appointment;
MessageBox.Show(app.Subject);
Another possible approach could be with BindingList<T> rather than a DataSet/DataTable. For example:
BindingList <Appointment> list = new BindingList<Appointment>();
list.Add(new Appointment(DateTime.Now, DateTime.Now.AddDays(2)));
list.Add(new Appointment(DateTime.Now, DateTime.Now.AddDays(5)));
ultraCalendarInfo1.DataBindingsForAppointments.DataSource = list;
Appointment app = ultraCalendarInfo1.Appointments.GetAppointmentFromBindingListObject(list[1]) as Appointment;
Let me know if you have any questions.
Regards
I tried your approach and it still fails on the GetAppointmentFromBindingListObject. Here's my code after using your suggestion:
Dim strImageFilename As String = GetColString(dScheduleJobRow("Drawing_Filename"))
If strImageFilename.Trim <> String.Empty Then
If System.IO.File.Exists(strImageFilename) = True Then
Dim fs As System.IO.FileStream
fs = New System.IO.FileStream(strImageFilename, IO.FileMode.Open, IO.FileAccess.Read)
'get all the appointments for this job and set the image...
Dim dScheduleDetailRows() As DataRow = Me.dsDataEntryItem.Tables("Schedule_Detail").Select("Schedule_Job_ID = " & GetColInteger(dScheduleJobRow("Schedule_Job_ID")).ToString, String.Empty, DataViewRowState.CurrentRows)
If dScheduleDetailRows.Length > 0 Then
For Each dScheduleDetailRow As DataRow In dScheduleDetailRows
Dim drv As DataRowView = Me.dsDataEntryItem.Tables("Schedule_Detail").DefaultView(Me.dsDataEntryItem.Tables("Schedule_Detail").Rows.IndexOf(dScheduleDetailRow))
If Not IsNothing(drv) Then
Dim objAppointment As Appointment = DirectCast(Me.CalendarInfo1.Appointments.GetAppointmentFromBindingListObject(drv), Appointment)
If Not IsNothing(objAppointment) Then
objAppointment.Appearance.Image = System.Drawing.Image.FromStream(fs)
End If
Next
fs.Close()
fs = Nothing
Hi,
I downgraded my test sample to version 12.1.20121.2135 and CLR 2.0 and everything works properly. Could you please tell me what is your current build (see attached screenshot). If you are using older build, you could donwload the latest available service release for version 12.1 from our site: Infragistics.com -> Account -> My Key and Downloads -> Service Releases If it is not the reason for this strange behavior, I`ll convert my sample to VB to exclude also this difference between our scenarios.
I am using the same build as you are.
I made a new sample, where I`m using your version and VB language, but I was not able to reproduce your issue. Could you please take a look at the attached sample and video file (please do not forget to change the connection string to your database) and feel free to modify this sample to reproduce your issue and revert it back to me. I`ll be glad to research it for you.
Let me know if you have any questions
Here is the sample
If you need any additional assistance don’t hesitate to ask.