dropdown list and databinding issue

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • phpmel
    New Member
    • Oct 2007
    • 69

    dropdown list and databinding issue

    hi guys,

    I am using Visual Studio 2005. I have a dropdown list that has an associated SQLdatasource. I also have a textbox below the dropdown list that allows you to add items to the table that the datasource is associated with.After entering a new item into the table that the datasource is tied to, i would like to "refresh" the dropdown list so this is what i did

    manuDropDownLis t.Items.Clear() ;
    manuDropDownLis t.DataBind();


    my problem is that i have the first item in the dropdown list as SELECT... and i set AppenddataBound Items=true in the drop down list properties however after databinding and stuff the SELECT... does not show up.
    Everything works fine except that the SELECT... does not come back
    How do i get it back?

    please help
  • shweta123
    Recognized Expert Contributor
    • Nov 2006
    • 692

    #2
    Hi,

    Please check that if you have added "Select.." string into dropdownlist at the time of refreshing it.
    e.g.

    Code:
    manuDropDownList.Items.Clear();
    
    //Add this statement if you want first item as "Select"
    manuDropDownList.Items.Add("Select..")
    manuDropDownList.DataBind();
    Originally posted by phpmel
    hi guys,

    I am using Visual Studio 2005. I have a dropdown list that has an associated SQLdatasource. I also have a textbox below the dropdown list that allows you to add items to the table that the datasource is associated with.After entering a new item into the table that the datasource is tied to, i would like to "refresh" the dropdown list so this is what i did

    manuDropDownLis t.Items.Clear() ;
    manuDropDownLis t.DataBind();


    my problem is that i have the first item in the dropdown list as SELECT... and i set AppenddataBound Items=true in the drop down list properties however after databinding and stuff the SELECT... does not show up.
    Everything works fine except that the SELECT... does not come back
    How do i get it back?

    please help

    Comment

    • prabunewindia
      New Member
      • Mar 2007
      • 199

      #3
      hi,
      Please check, where you placed the code to add "select"

      if you wrote this before dropdownlist.Da taBaind(), then the add item (i.e, "select") will be deleted when you bind the datasource.

      so please add the item after bind.

      Its better to use,

      dropdownlist.It ems.Insert(0,"s elect"); than add...

      Rajendra Prabu Elias

      Comment

      Working...