Can preselect databound listbox items

Discussion in 'ASP .Net Web Controls' started by Joel Barsotti, Jan 4, 2007.

  1. Hello,

    I'm binding in a list of search options from my database, the listbox is
    filled correctly, but I want all the items to be pre-selected. Doing the
    following doesn't seem to work.

    myDa.Fill(tempTable);
    productTypeList.DataSource = new DataView(tempTable);
    productTypeList.DataTextField = "productTypeName";
    productTypeList.DataValueField = "productType";
    productTypeList.DataBind();
    foreach(ListItem li in productTypeList.Items)
    {
    li.Selected = true;
    }


    Am I missing something to update the control?
    Joel Barsotti, Jan 4, 2007
    #1
    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. D. Shane Fowlkes
    Replies:
    0
    Views:
    557
    D. Shane Fowlkes
    Apr 7, 2004
  2. Isaac Wang via .NET 247

    How to preselect multiple items in listbox

    Isaac Wang via .NET 247, Apr 27, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    1,935
    =?Utf-8?B?QmluIFNvbmcsIE1DUA==?=
    Apr 27, 2004
  3. rodchar
    Replies:
    0
    Views:
    379
    rodchar
    Nov 26, 2007
  4. Nik
    Replies:
    0
    Views:
    115
  5. Manu
    Replies:
    0
    Views:
    159
Loading...

Share This Page