More in this section

Forums / Developing with Sitefinity / Bind datasource to FormDropDownList

Bind datasource to FormDropDownList

6 posts, 0 answered
  1. Shalaka
    Shalaka avatar
    50 posts
    Registered:
    24 Mar 2011
    16 Mar 2012
    Link to this post
    Hi,
    I am using sitefinity 4.4.
    I need to bind datatable to formdropdownlist control.
    where should i write code for that?
    What i have done is , i have inherited FormsControl and trying to override its events. but i am bot able to get the event wherein i can bind table to formdropdownlist control.

    Please help.. its urgent.

    Thanks & Regards,
    Shalaka.
  2. Stanislav Velikov
    Stanislav Velikov avatar
    1113 posts
    Registered:
    18 Sep 2017
    16 Mar 2012
    Link to this post
    Hello,

     I have attached a custom form control that have form dropdown with custom data source. I suppose this might be of help to you.

    All the best,
    Stanislav Velikov
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. Shalaka
    Shalaka avatar
    50 posts
    Registered:
    24 Mar 2011
    17 Mar 2012
    Link to this post
    Hi,
    Sorry. but i have not understood that how can i use this code which is provided by you....
    this code does not contain any dropdown list control.....

    Please reply.
  4. Shalaka
    Shalaka avatar
    50 posts
    Registered:
    24 Mar 2011
    19 Mar 2012
    Link to this post
    Is there any other alternative?
  5. Stanislav Velikov
    Stanislav Velikov avatar
    1113 posts
    Registered:
    18 Sep 2017
    21 Mar 2012
    Link to this post
    Hello,

    Excuse me I have attached the wrong control, here is the updated control with dropdown list prepopulated with custom data source.

    Greetings,
    Stanislav Velikov
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  6. Shalaka
    Shalaka avatar
    50 posts
    Registered:
    24 Mar 2011
    22 Mar 2012
    Link to this post
    Hi,
    Sorry. but whatever u have given is not as per my requirement.

    I need to bind dropdown which is on my formcontrol - which is sitefinity form control.
    i have attaching my cs file

    i have designed the form using sitefinity admin - content - form module.
    and i am overriding the submit button event.
    The form contain one dropdown control. and i need to bind that control.



    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Linq;
    using System.Net;
    using System.Net.Mail;
    using System.Text;
    using System.Text.RegularExpressions;
    using Telerik.Microsoft.Practices.EnterpriseLibrary.Logging;
    using Telerik.Sitefinity.Configuration;
    using Telerik.Sitefinity.Forms.Model;
    using Telerik.Sitefinity.Modules.Forms;
    using Telerik.Sitefinity.Modules.Forms.Web.UI;
    using Telerik.Sitefinity.Modules.Forms.Web.UI.Fields;
    using Telerik.Sitefinity.Services;
    using Telerik.Sitefinity.Web.UI.Fields;
    using Telerik.Sitefinity.Web.UI;
    using System.Data;

    namespace CustomFormControlTest
    {
        public class FormControlCustom: FormsControl
        {
            DataSet ds = new DataSet();

            #region Members

            /// <summary>
            /// This is the embedded control template for the FormControls.
            /// </summary>
            private const string layoutTemplateName = "CustomFormControlTest.Resources.FormsControl.ascx";
           
            #endregion

            #region Properties

            /// <summary>
            /// Gets or Sets the layout template name for the control.
            /// </summary>
            protected override string LayoutTemplateName
            {
                get
                {
                    return FormControlCustom.layoutTemplateName;
                }
            }
            #endregion

      

            protected override void ConfigureSubmitButton(System.Web.UI.Control control, string validationGroup)
            {
                var submit = control as FormSubmitButton;
                submit.Click += new EventHandler(submit_Click);
                base.ConfigureSubmitButton(control, validationGroup);
            }

         
            protected override void OnFieldValidation(FormFieldValidationEventArgs args)
            {
                var dat = Pagecaptua;

                if (dat.IsValid == false)
                    args.Cancel = true;
            }

     

            protected override void OnBeforeFormSave(CancelEventArgs args)
            {
                var dat = Pagecaptua;

                if (dat.IsValid == true)
                    args.Cancel = false;
                else
                    args.Cancel = true;
            }

            void submit_Click(object sender, EventArgs e)
            {
                //code for validating fields --
                foreach (var fieldControl in this.FieldControls)
                {
                    //  ((FormTextBox)fieldControl).FieldName=""
                    if (fieldControl is FormTextBox)
                    {
                        var data = ((FormTextBox)fieldControl).Value;
                        var date = fieldControl.MetaField.FieldName;

                      
                    }
                }
            }

     

            public static Telerik.Web.UI.RadCaptcha Pagecaptua { get; set; }
        }
    }



    Please reply
6 posts, 0 answered