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

[Solved] binding to database programmatically

1 Answer 191 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
tomas
Top achievements
Rank 1
tomas asked on 02 Jun 2009, 03:31 PM
Hello Telerik.

I am binding Scheduler to uknown dataset. The information about fields and resources is in a xml file.

Without resources everything is working, I can see appointments.

Resources code list I am generating from original data. Thus my dataset contains two tables (data and one resource code list table) like this:
<NewDataSet> 
<Table> 
  <hasRowRight>1</hasRowRight>   
  <n_nug_typ_id>50047</n_nug_typ_id>   
  <tnt_name>Discussion entry</tnt_name>   
  <author>Adam , [adam@enviss]</author>   
  <n_id>50140</n_id>   
  <n_wgid>5</n_wgid>   
  <n_tid>5</n_tid>   
  <n_code_name>Workflow test</n_code_name>   
  <n_date_created>2008-12-04T16:26:00+01:00</n_date_created>   
  <n_w_name>Discussion entry workflow</n_w_name>   
  <n_p_code_name>enviss</n_p_code_name>   
  <att_50312>etapa</att_50312>   
  <att_50312_key>50738</att_50312_key>   
  <att_50122>Memo</att_50122>   
  <att_50123>true</att_50123>   
  <att_50124>Workflow test</att_50124>   
  <att_50134>2009-06-03T00:00:00+02:00</att_50134>   
  <att_50135>2009-06-16T00:00:00+02:00</att_50135>   
  <att_50136>2009-06-09T00:00:00+02:00</att_50136>   
  <att_50137>2009-06-17T00:00:00+02:00</att_50137>   
  <att_50138>0</att_50138>   
  <att_50132>engineer2@enviss</att_50132>   
  <att_50132_key>50955</att_50132_key>   
  <att_50133>JF</att_50133>   
  <renderStatus>10</renderStatus>   
  </Table> 
<resources0> 
  <att_50132_key>50955</att_50132_key>   
  <att_50132>engineer2@enviss</att_50132>   
  </resources0> 
  </NewDataSet> 

Att_50132_key is is primary key for resources0 table and it is also foreign key in an appointment table TABLE.
Att_50132 is a text description.

My code is:
public void SetData(DataTable dtData)  
        {  
            DataSet ds = dtData.DataSet;  
 
            // datasetHelper implements selectDisctinct method to generate code-lists form existing appointments data. Adds new table to dataset.   
            DataSetHelper dsh = new DataSetHelper(ref ds);  
            XmlElement xeResources;  
            XmlElement xeResource;  
            string keyAttribute, valueAttribute;  
            ResourceType rt;  
 
            xeResources = (XmlElement) this.xeProperties.SelectSingleNode("//resources");  
 
            // existující resources se odstraní, protože dvojí pÅ™idání stejný resources způsobuje výjimku  
            this.scheduler.ResourceTypes.Clear();  
 
            for (int i = 0; i < xeResources.ChildNodes.Count; i++)  
            {  
                if (xeResources.ChildNodes[i] is XmlElement)  
                {  
                    xeResource = (XmlElement)xeResources.ChildNodes[i];  
                    keyAttribute = xeResource.GetAttribute("keyAttribute");  
                    valueAttribute = xeResource.GetAttribute("codeNameAttribute");  
                    dsh.SelectDistinct("resources" + i.ToString(), dtData, keyAttribute, valueAttribute);  
 
                    // resources databinding  
                    rt = new ResourceType(xeResource.GetAttribute("name"));  
                    rt.DataSource = ds.Tables["resources" + i.ToString()];  
                    rt.KeyField = keyAttribute;  
                    rt.ForeignKeyField = keyAttribute;  
                    rt.TextField = valueAttribute;  
                    this.scheduler.ResourceTypes.Add(rt);                     
                }  
            }  
              
            this.dtData = dtData;  
 
            // appointments databanding  
            this.scheduler.DataSource = dtData;  
 
            // one extra attribute no problem with this  
            this.scheduler.Attributes["n_nug_typ_id"] = "n_nug_typ_id";  
            this.scheduler.DataBind();  
        }  
 

This produces an error

Invalid member name.   
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.   
 
Exception Details: System.ArgumentException: Invalid member name.  
 
Source Error:   
 
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.    
 
Stack Trace:   
 
 
[ArgumentException: Invalid member name.]  
   System.ComponentModel.MemberDescriptor..ctor(String name, Attribute[] attributes) +157  
   System.ComponentModel.PropertyDescriptor..ctor(String name, Attribute[] attrs) +9  
   Telerik.Web.UI.Appointment.MapCommonResources(PropertyDescriptorCollection properties) +159  
   Telerik.Web.UI.Appointment.MapAttributesAndResourcesToProperties(PropertyDescriptorCollection originalProperties) +236  
   Telerik.Web.UI.Appointment.System.ComponentModel.ICustomTypeDescriptor.GetProperties() +27  
   System.ComponentModel.MergedTypeDescriptor.System.ComponentModel.ICustomTypeDescriptor.GetProperties() +14  
   System.ComponentModel.TypeDescriptor.GetPropertiesImpl(Object component, Attribute[] attributes, Boolean noCustomTypeDesc, Boolean noAttributes) +68  
   System.ComponentModel.TypeDescriptor.GetProperties(Object component) +10  
   System.Web.UI.DataBinder.GetPropertyValue(Object container, String propName) +53  
   System.Web.UI.DataBinder.Eval(Object container, String[] expressionParts) +92  
   System.Web.UI.DataBinder.Eval(Object container, String expression) +106  
   Telerik.Web.UI.Scheduling.AppointmentTemplate._recurrenceIcon_DataBinding(Object sender, EventArgs e) +49  
   System.Web.UI.Control.OnDataBinding(EventArgs e) +99  
   System.Web.UI.Control.DataBind(Boolean raiseOnDataBinding) +92  
   System.Web.UI.Control.DataBind() +15  
   System.Web.UI.Control.DataBindChildren() +211  
   System.Web.UI.Control.DataBind(Boolean raiseOnDataBinding) +102  
   System.Web.UI.Control.DataBind() +15  
   System.Web.UI.Control.DataBindChildren() +211  
   System.Web.UI.Control.DataBind(Boolean raiseOnDataBinding) +102  
   System.Web.UI.Control.DataBind() +15  
   System.Web.UI.Control.DataBindChildren() +211  
   System.Web.UI.Control.DataBind(Boolean raiseOnDataBinding) +102  
   System.Web.UI.Control.DataBind() +15  
   System.Web.UI.Control.DataBindChildren() +211  
   System.Web.UI.Control.DataBind(Boolean raiseOnDataBinding) +102  
   System.Web.UI.Control.DataBind() +15  
   System.Web.UI.Control.DataBindChildren() +211  
   System.Web.UI.Control.DataBind(Boolean raiseOnDataBinding) +102  
   System.Web.UI.Control.DataBind() +15  
   System.Web.UI.Control.DataBindChildren() +211  
   System.Web.UI.Control.DataBind(Boolean raiseOnDataBinding) +102  
   System.Web.UI.Control.DataBind() +15  
   Telerik.Web.UI.RadScheduler.CreateChildControls(Boolean bindFromDataSource) +430  
   Telerik.Web.UI.RadScheduler.CreateChildControls() +10  
   System.Web.UI.Control.EnsureChildControls() +87  
   System.Web.UI.Control.PreRenderRecursiveInternal() +44  
   System.Web.UI.Control.PreRenderRecursiveInternal() +171  
   System.Web.UI.Control.PreRenderRecursiveInternal() +171  
   System.Web.UI.Control.PreRenderRecursiveInternal() +171  
   System.Web.UI.Control.PreRenderRecursiveInternal() +171  
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +842  
 
   
 

what I am doing wrong?

Thank you very much.

Tom

1 Answer, 1 is accepted

Sort by
0
Peter
Telerik team
answered on 08 Jun 2009, 07:58 AM
Hello tomas,

Can you open a support ticket and send us a demo project of this problem? We are not sure how exactly you implement this.


Greetings,
Peter
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Scheduler
Asked by
tomas
Top achievements
Rank 1
Answers by
Peter
Telerik team
Share this question
or