You must Sign In to post a response.
  • Category: ASP.NET

    How to add value to dropdownlist with out using DB and also not maually

    In run mode as follows

    Factuly Name Textbox1
    Faculty Department Dropdownlist1
    (Accounts Department)
    (Admin Department)
    (Sales Department)
    (HR Department)

    In the above Dropdownlist1 4 Department is there.suppose i want to add one more department means how can i add with out adding manuallly to database.

    And also idont want to add in aspxpage manually like this as follows
    Dropdownlist1.items.add("Purchase Department)

    how to add value to dropdownlist in run mode.
    i want to typethe value in dropdownlist1.
    for that how can i usingc#.
  • #761583
    Hello Rao,

    It's programming and this is the pre defined control. You have to use pre defined or use defined methods to add the value to drop down list or else you can type in drop down list manually.

    One more thing i request you to please Choose As Best Answer to your previous threads so that we can know it whether you are satisfied with our answer or not.

    Hope you understand.

    Nirav Lalan
    DNS Gold Member
    "Failure is the path of least persistence"

  • #761588

    Maintain the data in to viewstate and based on viewstate data you can bind to your dropdownlist.


    DataTable dt=//get data from DB;


    //add your dynamic records to dt now.
    DataRow dr=dt.NewRow();
    //finally save this dt into viewstate.

    Whenever you want to display the details in dropdownlist use the above viewstate and bind it.

    Hope this will helpful to you....

    Give respect to your work, Instead of trying to impress your boss.

    Blog :

  • #761918

    Generally we can add the items to controls we can use 2 methods

    2.C# Code

    so you mention without add database then you mention no need server side means we can only one way add the client side ddl in your controls

    try this code but not runtime this

    <asp:DropDownList ID="drp1" runat="server">
    <asp:ListItem Text="" Value="Department"></asp:ListItem>

    if you need run time means try this code

    drp1.Items.Insert(0, "Department");

    Name : Dotnet Developer-2015
    Email Id :

    'Not by might nor by power, but by my Spirit,' says the LORD Almighty.

  • Sign In to post your comments