コード例 #1
0
    private void BindCountryDropDown(RadDropDownList dd_country, bool IncludeBlankSelection, String Country = "")
    {
        String    qry = "SELECT countryid, country, phonecode FROM dbd_country ORDER BY country";
        DataTable dt  = SQL.SelectDataTable(qry, null, null);

        dd_country.DataSource     = dt;
        dd_country.DataValueField = "countryid";
        dd_country.DataTextField  = "country";
        dd_country.DataBind();
        if (IncludeBlankSelection)
        {
            dd_country.Items.Insert(0, new DropDownListItem(String.Empty, String.Empty));
        }

        if (Country != "" && dd_country.FindItemByText(Country) != null)
        {
            dd_country.SelectedIndex = dd_country.FindItemByText(Country).Index;
        }
    }
コード例 #2
0
        /// <summary>
        /// Permite pararse en un item del DropDownList deacuerdo a su texto
        /// </summary>
        /// <param name="myDropDownList">Objeto DropDownList el cual actualizar</param>
        /// <param name="item_text">Texto a buscar en el DropDownLis</param>
        /// <remarks>
        /// <list> Creado: Enero 17 de 2013 - Ing. David Pineda </list>
        /// </remarks>
        public static void selectIndexByText(ref RadDropDownList myDropDownList, string item_text)
        {
            if ((myDropDownList == null))
            {
                throw new ArgumentNullException("El argumento myDropDownList es nulo");
            }

            if (item_text == string.Empty)
            {
                throw new ArgumentException("El argumento item_text esta vacio");
            }

            if (myDropDownList.Items.Count > 0)
            {
                try
                {
                    myDropDownList.SelectedIndex = myDropDownList.FindItemByText(item_text).Index;
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
        }