tags:

views:

33

answers:

3

I have a listbox which populated from using a datatable. I have a Add button in my page. On clicking the add button I want to insert a blank row in the listbox. This can be done easily by

ListBox_Admin.Items.Add("");

after this is done I want to select this item as in setfocus on this item.How do I do this.

+3  A: 

Something like this?

listBox1.Items.Add("");
listBox1.SelectedIndex = listBox1.Items.Count - 1;
kprobst
Works like a charm. Feeling sad I couldn't think this.Thanks!!!
gizgok
A: 

Try this

ListBox_Admin.Items.Add(item);
ListBox_Admin.SeletedItem = item;
tchrikch
A: 

Or:

ListBox_Admin.SelectedValue = "";
Ang
Did you try this
gizgok
yes, this is work
Ang