Issue on asp.net dropdownlist.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • nirmalsingh
    New Member
    • Sep 2006
    • 218

    Issue on asp.net dropdownlist.

    hai all.

    i have loaded a dropdownlist box using code.

    [HTML] cboUserGroup.Da taSource = loadGroupCombos ("").Tables[0];
    cboUserGroup.Da taTextField = "name";
    cboUserGroup.Da taValueField = "id";
    cboUserGroup.Da taBind();[/HTML]
    now the dropdownlist box have the values such as

    name---------------id
    --------------------------
    A ------------------- 1
    B-------------------- 2
    C-------------------- 3
    D-------------------- 4
    for eg selected text is 'A'
    now i want to change the selected text as 'B'
    i have tried a many ways such as
    [HTML]cboUserGroup.It ems.FindByValue ("B").Select ed = true;
    cboUserGroup.Se lectedItem.Sele cted = "B";
    cboUserGroup.Da taValueField.In dexOf("B");
    cboUserGroup.It ems.FindByValue ("B").Select ed = true;
    cboUserGroup.Da taBind();[/HTML]

    but it is not working,
    but
    [HTML]cboUserGroup.Se lectedIndex = 1;[/HTML] is working.

    and another major issue is when i used this the above method, selected index is
    changing but cboUserGroup_Se lectedIndexChan ged is not firing.

    Note: i used autopostback=tr ue for dropdown list.

    plz help me to solve this.
    thanx in advance.
  • Curtis Rutland
    Recognized Expert Specialist
    • Apr 2008
    • 3264

    #2
    Originally posted by nirmalsingh
    and another major issue is when i used this the above method, selected index is
    changing but cboUserGroup_Se lectedIndexChan ged is not firing.
    Well, what you could do is whenever you use the codebehind to change the selected index, you could follow that with a call to [CODE=cpp]cboUserGroup_Se lectedIndexChan ged(cboUserGrou p, null);[/CODE]

    Comment

    • nirmalsingh
      New Member
      • Sep 2006
      • 218

      #3
      thank you, now the event is firing.
      but the first problem is not solved, that is i cannot select desired option in combo box.

      Comment

      Working...