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

    Need detail about dropdownlist

    Dear Friends
    In my project i have 2 drop down box. also i populated data with dropdown in page load. now i try to show some value from database to drop down with out existing value.. but i couldn't implement this.. how its possible can any guide me.

    here i posted my code for dropdown

    if (!IsPostBack)
    itype.DataSource = new Transaction().GetAlLRecords_br(true);
    itype.DataTextField = "DepartmentName";
    itype.DataValueField = "CID";

    ddlBox3.DataSource = new Transaction().GetAlLRecords_uom(true);
    ddlBox3.DataTextField = "UName";
    ddlBox3.DataValueField = "UID";
  • #764599

    I'm not clear about your question, but if you want to show new values into dropdown and clear the existing values then use Clear(0 method to clear dropdown values.


    and then bind your new result into dropdown datasource.

    Hope this will helpful to you...

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

    Blog :

  • #764602
    Please elaborate your requirement, what you want to do exactly ? if my understanding is right, I think you need to bind one more additional data in dropdownlist with your existing values right ? when you bind dropdownlist to data column you can not add new item in it, so better to fill dropdownlist with datareader or dataset and then add some item in it
    after data bind you can use 'Items.Insert' method
    drpList.Items.Insert(0, new ListItem(String.Empty, String.Empty));
    drpList.SelectedIndex = 0;

    cause Items.Add is not used/working after databind

    Editor, DotNetSpider MVM
    Microsoft MVP 2014 [ASP.NET/IIS]

Sign In to post your comments