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

HtmlTextBox server side binding

2 Answers 112 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Pablo Tola
Top achievements
Rank 2
Pablo Tola asked on 27 Apr 2010, 03:59 PM
When I try to bind an HtmlTextBox server side no data is displayed on the report, I don't know when this stopped working because a client of mine just reported it happening after my last update to his system using the latest telerik Reporting build. This was working fine before that.

Here's the code, I can't find anything wrong with it.

private void GetAppointments()  
{  
 
    StartDate = new DateTime(2008, 10, 1);  
    EndDate = new DateTime(2008, 11, 1);  
    MemberId = 10;  
    Priority = null;  
    Color = null;  
    EmployeeId = null;  
 
    appointments = (from a in _context.Appointment  
                    where a.Start >= StartDate &&  
                        a.End < EndDate &&  
                        a.WorkOrderId > 0 &&  
                        (a.MemberId.Equals(MemberId) || MemberId == null) &&  
                        (a.WorkOrder.Job.Priority.Equals(Priority) || Priority == null) &&  
                        (a.Color.Equals(Color) || Color == null) &&  
                        (a.WorkOrder.WorkOrderResourceList.Select(r => (long?)r.EmployeeId).ToList().Contains(EmployeeId) || EmployeeId == null)  
                    orderby a.Start  
                    select a).ToList();  
 
}  
 
void Schedule_NeedDataSource(object sender, EventArgs e)  
{  
 
    GetAppointments();  
    tblAppointments.DataSource = appointments;  
 
}  
 
void htmlWorkOrdeDetails_ItemDataBound(object sender, EventArgs e)  
{  
    Telerik.Reporting.Processing.HtmlTextBox details = (Telerik.Reporting.Processing.HtmlTextBox)sender;  
 
    var workOrder = details.DataObject["WorkOrder"as Entities.WorkOrder;  
    var color = (AppointmentColor)details.DataObject["ColorAppointmentColor"];  
    var subject = (string)details.DataObject["Subject"];  
 
    var workOrderDetails = new System.Text.StringBuilder();  
    if (workOrder != null)  
    {  
        var job = workOrder.Job;  
        var jobSite = job.Address;  
        var customer = job.Customer;  
 
        var resources = string.Empty;  
 
        switch (workOrder.AssignedToType)  
        {  
            case 0:  
                resources = "Not Assigned";  
                break;  
            case 1:  
                resources = string.Join(", ", workOrder.WorkOrderResourceList.Select(r => (r.Employee.FirstName + " " + r.Employee.LastName)).ToArray());  
                break;  
            case 2:  
                resources = workOrder.AssignedToContractor.Name;  
                break;  
        }  
 
        workOrderDetails.Append("<div style='background-color: white'>");  
        workOrderDetails.AppendFormat("<b>Work Order # {0}</b><br/>", workOrder.Number);  
        workOrderDetails.AppendFormat("<b>Job Site:</b> {0}, {1}, {2}. {3}<br/>", HttpUtility.HtmlEncode(jobSite.AddressMember), HttpUtility.HtmlEncode(jobSite.City.Name), jobSite.State.Abbreviation, jobSite.ZipCode.ZipCodeMember);  
        workOrderDetails.AppendFormat("<b>Customer:</b> {0}<br/>",HttpUtility.HtmlEncode(customer.Name));  
        workOrderDetails.AppendFormat("<b>Job Name:</b> {0}<br/>", HttpUtility.HtmlEncode(job.Name));  
        workOrderDetails.AppendFormat("<b>Assigned To:</b> {0}<br/>", HttpUtility.HtmlEncode(resources));  
        workOrderDetails.AppendFormat("<b>Notes:</b> {0}"string.IsNullOrEmpty(subject) ? "N/A" : HttpUtility.HtmlEncode(subject));  
        workOrderDetails.Append("</div>");  
    }  
 
    details.Style.BorderWidth.Default = new Unit(1);  
    details.Style.BorderColor.Default = ColorTranslator.FromHtml(color.Name);  
    details.Style.BackgroundColor = ColorTranslator.FromHtml(color.Name);  
    details.Value = workOrderDetails.ToString();  
}  
 

2 Answers, 1 is accepted

Sort by
0
Accepted
Peter
Telerik team
answered on 30 Apr 2010, 09:33 AM
Hello Pablo Tola,

You should be using the ItemDataBinding event instead for such purposes, because the ItemDataBound is fired just after the item is bound to data. Although this used to work in previous versions, it was wrong, and the new behavior is the expected one.

Regards,
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.
0
Andrea
Top achievements
Rank 2
Iron
answered on 15 Nov 2011, 02:41 PM
Uhm.... so what is the purpose of ItemDataBound event, if I can't modify the databound item?

Best Regards.
Tags
General Discussions
Asked by
Pablo Tola
Top achievements
Rank 2
Answers by
Peter
Telerik team
Andrea
Top achievements
Rank 2
Iron
Share this question
or