Change the position of the item in listBox

S

simon

I have list box populated with the dataReader. Then I add one item and I
want that this item would be the first one in the listBox.
Now, It's the last. Can I change the position of the item in the listBox
from the last to the first?


lstMedia.DataSource() = funkcije.createDataReader(sql, True)
lstMedia.DataValueField = "med_id"
lstMedia.DataTextField = "med_name"
lstMedia.DataBind()

Dim novItem As New ListItem

novItem.Text = "..."
novItem.Value = "0"
novItem.Selected = True
lstMedia.Items.Add(novItem)
 
M

Mohamed Sharaf

Hi Simon,
You can try one of the following
lstMedia.DataSource() = funkcije.createDataReader(sql, True)
lstMedia.DataValueField = "med_id"
lstMedia.DataTextField = "med_name"
lstMedia.DataBind()
lstMedia.items.insert(0,"Mohamed") ' If you don't want to add value

or
dim myListItem as new ListItem("Mohamed","150") 'if you want to add a
value to the item
lstMedia.items.insert(0,myListItem)

Best Regards
Mohamed Sharaf
 
S

simon

thank you, it works now.
I missed the method insert, I only new for add method:)

Regards,
Simon
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top