Search This Blog

Saturday, 1 September 2012

Data bind Dropdownlist in

Fill drop down list dynamically using c# in need to write method inside IspostBack condition to avoid multiple times binding.Below Example using Dictionary collection to fill dropdownlist,we can fetch data from database as well.

protected void Page_Load(object sender, EventArgs e)
       firstName = "vinod";
       if (!IsPostBack)

   public void fillDropdownlist()
       Dictionary<intstring> obj = new Dictionary<intstring>();
       obj.Add(1, "vinod");
       obj.Add(2, "hari");
       DropDownList1.DataValueField = "Key";
       DropDownList1.DataTextField = "Value";
       DropDownList1.DataSource = obj;
     DropDownList1.Items.Insert(0, "--Select--");

    City : 
    <asp:DropDownList ID="DropDownList1" runat="server">                                   

Fill dropdownlist dynamically in          


No comments:

Post a Comment