asp:listbox and selected value within a repeater

Discussion in 'ASP .Net Web Controls' started by John Giblin, Nov 26, 2003.

  1. John Giblin

    John Giblin Guest

    I have a ListBox within a repeater tag and I am trying to set the selected
    value. I tried the following without success. I was also trying to make a
    method for the selectedindex but I do not know how to pass the instance of
    this asp:listbox control.

    <asp:ListBox id="ListBox1" name="ListBox1" DataSource='<%#
    GetDropDownQuantities( (BasketLine)DataBinder.Eval(Container,"DataItem"))
    %>'
    Rows="1"
    CssClass="orderselect"
    SelectionMode=Single
    runat="server">
    </asp:ListBox>


    public ListItemCollection GetDropDownQuantities( BasketLine bl)
    {
    ListItemCollection listBoxData = new ListItemCollection();

    int x=0;
    bool isSelected = false;
    while (x++ < 20)
    {
    ListItem li = new ListItem();
    li.Value = x.ToString();
    li.Text = x.ToString();
    if (x==bl.Quantity && !isSelected)
    {
    li.Selected = true;
    isSelected = true;
    }
    listBoxData.Add(li);

    }
    return listBoxData;
    }

    thanks

    John
     
    John Giblin, Nov 26, 2003
    #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. Moe Sizlak
    Replies:
    4
    Views:
    781
    Moe Sizlak
    Jul 20, 2004
  2. Big E

    Listbox Selected Value

    Big E, Jul 26, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    12,819
    Adam Barker
    Jul 26, 2004
  3. Joey
    Replies:
    2
    Views:
    1,162
  4. =?Utf-8?B?TmFtZXNwYWNl?=
    Replies:
    0
    Views:
    532
    =?Utf-8?B?TmFtZXNwYWNl?=
    Jun 1, 2005
  5. K B
    Replies:
    2
    Views:
    683
Loading...

Share This Page