private void PanelForm_Activate(object sender, System.EventArgs e)
 {
     PanelList.DataSource    = GetCustomersData(PanelFormTextBox.Text);
     PanelList.DataMember    = "Customers";
     PanelList.DataTextField = "ContactName";
     PanelList.DataBind();
 }
Example #2
0
        private void QueryCmd_Click(object sender, System.EventArgs e)
        {
            ActiveForm = ResultsForm;

            CustList.DataSource    = GetCustomersByName(NameTextBox.Text);
            CustList.DataMember    = "Customers";
            CustList.DataTextField = "ContactName";
            CustList.DataBind();
        }
        private void Form1_Activate(object sender, System.EventArgs e)
        {
            DataSet ds = GetCustomersData();

            List1.DataSource    = ds;
            List1.DataMember    = "Customers";
            List1.DataTextField = "ContactName";
            List1.DataBind();
        }
 // A helper function to do the common code for DataBind and
 // RenderChildren.
 private void DataBindAndRender(HtmlMobileTextWriter writer,
                                List list,
                                ArrayList arr)
 {
     list.DataSource = arr;
     list.DataBind();
     list.Visible = true;
     list.RenderControl(writer);
 }
 private void DataBindListWithEmptyValues(List list, int arraySize)
 {
     ArrayList arr = new ArrayList();
     for (int i = 0; i < arraySize; i++)
     {
         arr.Add("");
     }
     list.DataSource = arr;
     list.DataBind();
 }
Example #6
0
        /// <summary>
        ///    <para>
        ///       Gets the HTML to be used for the design-time representation
        ///       of the control.
        ///    </para>
        /// </summary>
        /// <returns>
        ///    <para>
        ///       The design-time HTML.
        ///    </para>
        /// </returns>
        /// <remarks>
        ///    <para>
        ///       The rule for handing DesignTimeHTML is similar to System.Web.UI.DataList control,
        ///       if list has a HTML templateset, then generate sample data from static data or
        ///       dynamic data (if static data does not exist). Show the sample data with templates
        ///       applied.
        ///    </para>
        /// </remarks>
        protected override String GetDesignTimeNormalHtml()
        {
            IEnumerable selectedDataSource = null;
            String      oldDataTextField = null, oldDataValueField = null;
            bool        dummyDataSource = false;

            DesignerTextWriter writer = new DesignerTextWriter(true);

            // Apply the current device specific
            if (_list.DeviceSpecific != null)
            {
                _list.DeviceSpecific.SetDesignerChoice(CurrentChoice);
            }

            MobileListItemCollection items = _list.Items;

            Debug.Assert(items != null, "Items is null in LisControl");
            MobileListItem[] oldItems = items.GetAll();

            // Hack: If List is templated, use DataBind() to create child controls.
            //       If it is empty, use dummy data source to create fake child controls.
            if (_list.IsTemplated || items.Count == 0)
            {
                int sampleRows = items.Count;

                // If List does not contain any items, use five dummy items.
                if (sampleRows == 0)
                {
                    sampleRows = 5;
                }

                // try designtime databinding.
                selectedDataSource = GetResolvedSelectedDataSource();

                // Recreate the dummy data table, if number of items changed. BUG from webforms
                if (sampleRows != _numberItems)
                {
                    OnDummyDataTableChanged();

                    // keep the new item count
                    _numberItems = sampleRows;
                }

                IEnumerable designTimeDataSource =
                    GetDesignTimeDataSource(selectedDataSource, sampleRows, out dummyDataSource);

                // If dummy datasource is applied, change the data fields so that
                // dummy source will be rendered.
                if (dummyDataSource)
                {
                    oldDataTextField     = _list.DataTextField;
                    oldDataValueField    = _list.DataValueField;
                    _list.DataTextField  = "Column0";
                    _list.DataValueField = "Column1";
                }

                try
                {
                    _list.DataSource = designTimeDataSource;
                    _list.DataBind();
                    _list.Adapter.Render(writer);
                }
                finally
                {
                    _list.DataSource = null;

                    // restore the old items since databinding creates items from templates.
                    _list.Items.SetAll(oldItems);

                    // clear all child controls created by databinding.
                    _list.Controls.Clear();

                    if (dummyDataSource)
                    {
                        _list.DataTextField  = oldDataTextField;
                        _list.DataValueField = oldDataValueField;
                    }
                }
            }
            // Otherwise, list only contains static items, just render it directly.
            else
            {
                _list.Adapter.Render(writer);
            }

            return(writer.ToString());
        }