Can not add to/modify dropdown list after datasource has been load

Discussion in 'ASP .Net' started by =?Utf-8?B?TWVyZGFhZA==?=, Oct 20, 2004.

  1. Hi,

    In my dropdown I bind to a datasource. After that I try to do one of the
    following:
    1. Add an Item to the dropdown using dd.Items.Add(newe ListItem("textstr"));
    2. Change the text of an existing item in the dropdown. For this one I use
    the
    following:pubDD.Items[pubDD.Items.IndexOf(pubDD.Items.FindByText("textstr"))].Text=otherText;

    Neither one works.

    Thanks for any suggestions....
    =?Utf-8?B?TWVyZGFhZA==?=, Oct 20, 2004
    #1
    1. Advertising

  2. After databinding try dd.Items.Insert(...)

    --
    I hope this helps,
    Steve C. Orr, MCSD, MVP
    http://Steve.Orr.net



    "Merdaad" <> wrote in message
    news:...
    > Hi,
    >
    > In my dropdown I bind to a datasource. After that I try to do one of the
    > following:
    > 1. Add an Item to the dropdown using dd.Items.Add(newe
    > ListItem("textstr"));
    > 2. Change the text of an existing item in the dropdown. For this one I
    > use
    > the
    > following:pubDD.Items[pubDD.Items.IndexOf(pubDD.Items.FindByText("textstr"))].Text=otherText;
    >
    > Neither one works.
    >
    > Thanks for any suggestions....
    Steve C. Orr [MVP, MCSD], Oct 20, 2004
    #2
    1. Advertising

  3. Re: Can not add to/modify dropdown list after datasource has been

    Thanks but it didn't work:
    pubDD.Items.Insert(recCnt,new ListItem( "WINK", recCnt.ToString())); For
    the new insert
    That's for inserting a new one.

    Modifying an existing one didn't work either.

    "Steve C. Orr [MVP, MCSD]" wrote:

    > After databinding try dd.Items.Insert(...)
    >
    > --
    > I hope this helps,
    > Steve C. Orr, MCSD, MVP
    > http://Steve.Orr.net
    >
    >
    >
    > "Merdaad" <> wrote in message
    > news:...
    > > Hi,
    > >
    > > In my dropdown I bind to a datasource. After that I try to do one of the
    > > following:
    > > 1. Add an Item to the dropdown using dd.Items.Add(newe
    > > ListItem("textstr"));
    > > 2. Change the text of an existing item in the dropdown. For this one I
    > > use
    > > the
    > > following:pubDD.Items[pubDD.Items.IndexOf(pubDD.Items.FindByText("textstr"))].Text=otherText;
    > >
    > > Neither one works.
    > >
    > > Thanks for any suggestions....

    >
    >
    >
    =?Utf-8?B?TWVyZGFhZA==?=, Oct 20, 2004
    #3
  4. Re: Can not add to/modify dropdown list after datasource has been

    any other ideas?

    "Merdaad" wrote:

    > Thanks but it didn't work:
    > pubDD.Items.Insert(recCnt,new ListItem( "WINK", recCnt.ToString())); For
    > the new insert
    > That's for inserting a new one.
    >
    > Modifying an existing one didn't work either.
    >
    > "Steve C. Orr [MVP, MCSD]" wrote:
    >
    > > After databinding try dd.Items.Insert(...)
    > >
    > > --
    > > I hope this helps,
    > > Steve C. Orr, MCSD, MVP
    > > http://Steve.Orr.net
    > >
    > >
    > >
    > > "Merdaad" <> wrote in message
    > > news:...
    > > > Hi,
    > > >
    > > > In my dropdown I bind to a datasource. After that I try to do one of the
    > > > following:
    > > > 1. Add an Item to the dropdown using dd.Items.Add(newe
    > > > ListItem("textstr"));
    > > > 2. Change the text of an existing item in the dropdown. For this one I
    > > > use
    > > > the
    > > > following:pubDD.Items[pubDD.Items.IndexOf(pubDD.Items.FindByText("textstr"))].Text=otherText;
    > > >
    > > > Neither one works.
    > > >
    > > > Thanks for any suggestions....

    > >
    > >
    > >
    =?Utf-8?B?TWVyZGFhZA==?=, Oct 21, 2004
    #4
  5. Re: Can not add to/modify dropdown list after datasource has been

    You don't have to use databinding.
    You can iterate through the datasource and add each item to the dropdownlist
    with a few lines of code.
    Then you can add anything you want without such hassles.

    --
    I hope this helps,
    Steve C. Orr, MCSD, MVP
    http://Steve.Orr.net


    "Merdaad" <> wrote in message
    news:D...
    > any other ideas?
    >
    > "Merdaad" wrote:
    >
    >> Thanks but it didn't work:
    >> pubDD.Items.Insert(recCnt,new ListItem( "WINK", recCnt.ToString())); For
    >> the new insert
    >> That's for inserting a new one.
    >>
    >> Modifying an existing one didn't work either.
    >>
    >> "Steve C. Orr [MVP, MCSD]" wrote:
    >>
    >> > After databinding try dd.Items.Insert(...)
    >> >
    >> > --
    >> > I hope this helps,
    >> > Steve C. Orr, MCSD, MVP
    >> > http://Steve.Orr.net
    >> >
    >> >
    >> >
    >> > "Merdaad" <> wrote in message
    >> > news:...
    >> > > Hi,
    >> > >
    >> > > In my dropdown I bind to a datasource. After that I try to do one of
    >> > > the
    >> > > following:
    >> > > 1. Add an Item to the dropdown using dd.Items.Add(newe
    >> > > ListItem("textstr"));
    >> > > 2. Change the text of an existing item in the dropdown. For this one
    >> > > I
    >> > > use
    >> > > the
    >> > > following:pubDD.Items[pubDD.Items.IndexOf(pubDD.Items.FindByText("textstr"))].Text=otherText;
    >> > >
    >> > > Neither one works.
    >> > >
    >> > > Thanks for any suggestions....
    >> >
    >> >
    >> >
    Steve C. Orr [MVP, MCSD], Oct 21, 2004
    #5
  6. =?Utf-8?B?TWVyZGFhZA==?=

    neskire

    Joined:
    Nov 7, 2006
    Messages:
    1
    Set appendDataBoundItems

    Do as above but set the property 'appenDataBoundItems' on the dropdownlist,
    this merge the data from the database with your static bound item.
    neskire, Nov 7, 2006
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Tom Vergote
    Replies:
    4
    Views:
    458
    Tom Vergote
    Jan 29, 2004
  2. =?Utf-8?B?TWVyZGFhZA==?=
    Replies:
    0
    Views:
    354
    =?Utf-8?B?TWVyZGFhZA==?=
    Oct 20, 2004
  3. Jim Bancroft
    Replies:
    4
    Views:
    9,209
    Saravana
    Jan 6, 2005
  4. Replies:
    4
    Views:
    1,062
    Gibble
    May 10, 2007
  5. bill.wu
    Replies:
    0
    Views:
    293
    bill.wu
    Jan 17, 2008
Loading...

Share This Page