Give A ResourceType Combobox a value

3 posts, 0 answers
  1. TB
    TB avatar
    23 posts
    Member since:
    Jun 2010

    Posted 31 Jan 2014 Link to this post

    1.I have a rad scheduler. Inside I have one ResourceType that binds a sqldatasource. I want to be able programatic(from code behind) to set the selectedvalue of the resourcetype. The desired value can change. Can someone please help me with this problem?

    Example:

    I have inside .aspx

                        <ResourceTypes>
                            <telerik:ResourceType KeyField="ID_OPERATIE" Name="Operatie" TextField="denumire"
                                ForeignKeyField="ID_OPERATIE" DataSourceID="dsOperatie" AllowMultipleValues="false">
                            </telerik:ResourceType>
                            <telerik:ResourceType KeyField="ID_SALA" Name="Sala" TextField="nume" ForeignKeyField="ID_SALA"
                                DataSourceID="dsSala" AllowMultipleValues="false"></telerik:ResourceType>
                        </ResourceTypes>

    inside FormCreated in code behind

    RadComboBox cbResOperatie = (RadComboBox)e.Container.FindControl("ResOperatie");
                    cbResOperatie.Width = cb_echipament.Width;
                    cbResOperatie.Height = 200;
                    cbResOperatie.Filter = RadComboBoxFilter.Contains;
                    cbResOperatie.SelectedIndexChanged += new RadComboBoxSelectedIndexChangedEventHandler(cbResOperatie_SelectedIndexChanged);
                    cbResOperatie.AutoPostBack = true;

    and inside cbResOperatie_SelectedIndexChanged (when the value of the Operatie changes) I need to be able to change the selected value of the  resource field Sala. Please help. 

    2.Another problem I use a SelectedIndexChanged handler that was bound programaticly inside FormCreated of the RadScheduler for another ResourceType. Can some one tell me why e.Value is displaying a long string like 'cvxbvxcbxcghfsfgf' instead of an number representing ForeignKeyField value? Please help. 

    Example:

    RadComboBox cbResOperatie = (RadComboBox)e.Container.FindControl("ResOperatie");
                    cbResOperatie.Width = cb_echipament.Width;
                    cbResOperatie.Height = 200;
                    cbResOperatie.Filter = RadComboBoxFilter.Contains;
                    cbResOperatie.SelectedIndexChanged += new RadComboBoxSelectedIndexChangedEventHandler(cbResOperatie_SelectedIndexChanged);
                    cbResOperatie.AutoPostBack = true;

    and inside cbResOperatie_SelectedIndexChanged we have as a parameter e.Value.


  2. TB
    TB avatar
    23 posts
    Member since:
    Jun 2010

    Posted 31 Jan 2014 Link to this post

    My problem occurs during the insert/edit of an appointment and before clicking the save button of the radscheduler edit/insert form

    My client code:

    RadScheduler

    <telerik:RadScheduler ID="SchProgramariEchipament" runat="server" DataDescriptionField="DESCRIERE"
                        DataEndField="DATA_END" DataKeyField="ID" DataSourceID="dsProgramareEchipament"
                        DataStartField="DATA_START" DataSubjectField="SUBIECT" Skin="Windows7" StartInsertingInAdvancedForm="True"
                        OnAppointmentCancelingEdit="SchProgramariEchipament_AppointmentCancelingEdit"
                        AppointmentStyleMode="Default" OnAppointmentInsert="SchProgramariEchipament_AppointmentInsert"
                        Culture="ro" OnAppointmentUpdate="SchProgramariEchipament_AppointmentUpdate"
                        OnAppointmentDelete="SchProgramariEchipament_AppointmentDelete" OnAppointmentDataBound="SchProgramariEchipament_AppointmentDataBound"
                        OnFormCreated="SchProgramariEchipament_FormCreated" EditFormDateFormat="dd/MM/yyyy"
                        FirstDayOfWeek="Monday" LastDayOfWeek="Sunday" EnableExactTimeRendering="true"
                        CustomAttributeNames="id_aparatura" OverflowBehavior="Auto">
                        <Localization AdvancedNewAppointment="Programare Echipament Nou" AdvancedSubject="Subiect"
                            ConfirmDeleteText="Vrei sa stergeti programarea?" ConfirmDeleteTitle="Vreti sa stergeti programarea?"
                            ConfirmOK="Da" ConfirmCancel="Nu" AllDay="Toata Ziua" HeaderDay="Zi" HeaderMonth="Luna"
                            HeaderToday="Azi" HeaderWeek="Saptamana" Save="Salvare" Cancel="Anuleaza" Show24Hours="24 ore..."
                            ShowBusinessHours="Perioada de Serviciu" />
                        <AdvancedForm Modal="false">
                        </AdvancedForm>
                        <AdvancedForm DateFormat="dd/MM/yyyy" />
                        <ExportSettings OpenInNewWindow="True">
                        </ExportSettings>
                        <ResourceTypes>
                            <telerik:ResourceType KeyField="ID_OPERATIE" Name="Operatie" TextField="denumire"
                                ForeignKeyField="ID_OPERATIE" DataSourceID="dsOperatie" AllowMultipleValues="false">
                            </telerik:ResourceType>
                            <telerik:ResourceType KeyField="ID_SALA" Name="Sala" TextField="nume" ForeignKeyField="ID_SALA"
                                DataSourceID="dsSala" AllowMultipleValues="false"></telerik:ResourceType>
                            <telerik:ResourceType KeyField="ID_OPERATIE" Name="Protocol" TextField="nume_protocol"
                                ForeignKeyField="ID_OPERATIE" DataSourceID="dsProtocol" AllowMultipleValues="false">
                            </telerik:ResourceType>
                        </ResourceTypes>
                        <ResourceStyles>
                        </ResourceStyles>
                        <AppointmentTemplate>
                            <div style="font-style: italic; width: 100%">
                                Subiect:
                                <%# Eval("Subject") %></div>
                            <div style="font-style: italic; width: 100%; visibility: hidden">
                                Operatie:
                                <%# Eval("Operatie.Text")%></div>
                            <div style="font-style: italic; width: 100%; visibility: hidden">
                                Sala Operatie:
                                <%# Eval("Sala.Text")%></div>
                        </AppointmentTemplate>
                        <AppointmentContextMenuSettings EnableDefault="true"></AppointmentContextMenuSettings>
                    </telerik:RadScheduler>
                    <asp:SqlDataSource ID="dsProgramareEchipament" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
                        DeleteCommand="DELETE FROM PROGRAMARE_ECHIPAMENT WHERE ID=:original_ID" OldValuesParameterFormatString="original_{0}"
                        ProviderName="<%$ ConnectionStrings:ConnectionString.ProviderName %>" SelectCommand="SELECT ID,ID_ECHIPAMENT,SUBIECT,DESCRIERE,DATA_START,DATA_END,E_PERIOADA_STERILIZARE,ID_OPERATIE,ID_SALA FROM PROGRAMARE_ECHIPAMENT where ID_ECHIPAMENT=:ID_ECHIPAMENT"
                        OnSelecting="dsProgramareEchipament_OnSelecting">
                        <DeleteParameters>
                            <asp:Parameter Name="original_ID" Type="Decimal" />
                        </DeleteParameters>
                        <SelectParameters>
                            <asp:Parameter Name="ID_ECHIPAMENT" Type="Decimal" />
                        </SelectParameters>
                    </asp:SqlDataSource>                                                                                                                                                                                                                                                                                                                                                                                                                               In  cbResOperatie_SelectedIndexChanged                                                                                                                                                             if I asign the sqldatasource  to the RadComboBox like :                                                                                                                                          

     RadComboBox cbResSala = ((RadComboBox)sender).Parent.FindControl("ResSala") as RadComboBox;
                    cbResSala.Width = cb_echipament.Width;
                    cbResSala.Height = 200;
                    cbResSala.Filter = RadComboBoxFilter.Contains;
                    cbResSala.DataTextField = "nume";
                    cbResSala.DataValueField = "ID_SALA";
                    cbResSala.DataSourceID = "dsSala";
                    cbResSala.SelectedValue = "" + id_sala;                                                                                                                                                                                                                                                                                                                                                                                                            I get an error when I click the save button of the appointment edit/insert form. It doesn't even trigger the AppoinmentInsert or AppointmentUpdate events. The Error is  inside the attached file. Hope it helps and is clearer than my first post.
    Thank you for your time and help.
     
                                                                                                                              



  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Boyan Dimitrov
    Admin
    Boyan Dimitrov avatar
    1746 posts

    Posted 05 Feb 2014 Link to this post

    Hello,

    Thank you for contacting Telerik Support.

    I would like to clarify that we highly recommend to avoid using auto post back functionality of the RadComboBox within the advanced form. As far as I understand you want to set some additional settings for the RadComboBox such as: Filter option and set the data source and fields. Please note that the RadComboBox controls is bound to the resource data source internally and changing its data source might cause some problems.

    In order to add or change some RadComboBox settings I would suggest using the advanced form as a completely separate user control. This way you have more control on the controls within the advanced form, so you can set filter options, width, height and etc. Please refer to this help resource that provides an example of the RadScheduler will server-side and client binding. Please note that the advanced form is located in a separate user control.

    Hope that this will be helpful.

    Regards,
    Boyan Dimitrov
    Telerik
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the UI for ASP.NET AJAX, subscribe to the blog feed now.
Back to Top