HtmlTextBox server side binding

3 posts, 1 answers
  1. Pablo Tola
    Pablo Tola avatar
    43 posts
    Member since:
    Nov 2007

    Posted 27 Apr 2010 Link to this post

    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)  
        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";  
                case 1:  
                    resources = string.Join(", ", workOrder.WorkOrderResourceList.Select(r => (r.Employee.FirstName + " " + r.Employee.LastName)).ToArray());  
                case 2:  
                    resources = workOrder.AssignedToContractor.Name;  
            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));  
        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. Answer
    Peter avatar
    1629 posts

    Posted 30 Apr 2010 Link to this post

    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.

    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.
  3. Andrea
    Andrea avatar
    67 posts
    Member since:
    Jan 2005

    Posted 15 Nov 2011 Link to this post

    Uhm.... so what is the purpose of ItemDataBound event, if I can't modify the databound item?

    Best Regards.
Back to Top