Just an Items.Add question

3 posts, 0 answers
  1. William Gollnick
    William Gollnick avatar
    17 posts
    Member since:
    May 2006

    Posted 02 May 2011 Link to this post

    I'm new to these controls. Normally to add an item to a listbox webcontrol I just had to do
     --->>>>  listbox1.items.add("value here") and all was right with the world

    Now using the RadListBox I can not do this. I have tried using the RadListBoxItem
    DIm itemout as RadListBoxItem
    itemout.text = "some value"
    radlistbox1.Items.add(itemout)        

    BUT using this approach I get compiler error

    --->>    Could not find a match for method 'RadListBox1.Items.Add' for the given parameter types: String.

    How do I just add a simple value to my listbox???

    Help

    gollnick

  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 03 May 2011 Link to this post

    Hello Wiliam,

    Here is a sample code to achieve your requirement.
    aspx:
    <telerik:RadListBox ID="RadListBox1" Height="150px"  runat="server". . . . . . >
    </telerik:RadListBox>

    VB:
    Protected Sub Button1_Click(sender As Object, e As EventArgs)
        Dim item As New RadListBoxItem()
        item.Text = "New"
        RadListBox1.Items.Add(item)
    End Sub

    Also take a look at the following demo.
    ListBox / Add/Remove/Disable items.

    Thanks,
    Shinu.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. William Gollnick
    William Gollnick avatar
    17 posts
    Member since:
    May 2006

    Posted 03 May 2011 Link to this post

    Thank you ... I did not (duh) NEW the item first........
Back to Top