Search

Tuesday, April 28, 2015
0 comments

How to bind Dropdownlist with whole english characters in ASP.NET C#

5:19 AMTuesday, April 28, 2015
I want to say that how to add English alphabets at run time in DropdownList. A intermediate programmer know that each char contain a ASCII value like 65 is a ASCII value of letter 'A'. Similarly again 66 to 90 is a ASCII value of Letter B to Z.  So add a DropdownList in the design page also bind with Alphabet public property. Look like this:

Source page:
<asp:DropDownList ID="Letters" DataSource='<%# Alphabet %>' runat="server" />

Code Behind Page:
public partial class Bynamejobsearch : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            DataBind();
        }
    }
    private List<char> _Alphabet;
    protected List<char> Alphabet
    {
        get
        {
            if (_Alphabet == null)
            {
                _Alphabet = new List<char>();
                for (int i = 65; i < 91; i++)
                {
                    _Alphabet.Add(Convert.ToChar(i));
                }
            }
            return _Alphabet;
        }
    }
}
In this program i have a list of type char. Use for loop which is start from 65 to 90. Add this char in the list one by one.
How to bind Dropdownlist with whole english characters in ASP.NET C#

Protected by Copyscape Online Copyright Protection Software

0 comments :

Post a Comment

 
Toggle Footer
Top