dropdown looks empty, but has item

C

Cirene

In a certain condition I want to 'detach' a dropdownlist from it's
datasource, clear it, and put in my own items via code.

I tried it like this....

ddlCreatedBy.DataSource = ""
ddlCreatedBy.DataSourceID = ""
ddlCreatedBy.DataTextField = ""
ddlCreatedBy.DataValueField = ""
ddlCreatedBy.Items.Clear()
:
:
Dim li As New ListItem(Membership.GetUser.UserName,
iCompanyUserId)
ddlCreatedBy.Items.Add(li)
ddlCreatedBy.SelectedIndex = 0
ddlCreatedBy.Enabled = False

I can see that ddlCreatedBy has 0 items before and 1 item after the Add, but
the dropdownlist shows up with no items.

Any idea why?

Thanks!
 
M

Manish

Hi Cirene,

I tried the following code in the Page_load event and it shows the text as
"New Text" in the Dropdownlist control.

Me.DropDownList1.DataSourceID = ""
Me.DropDownList1.Items.Clear()
Me.DropDownList1.Items.Add("New Text")

Regards,
Manish
www.ComponentOne.com
 
C

Cirene

Everything, including respone.write of the listbox item count and first
item, indicates that it's working.

But, on the browser screen the listbox APPEARS empty.

Is it because of how i'm clearing out the datasource stuff?
 
C

Cirene

Any ideas on this?

Cirene said:
Everything, including respone.write of the listbox item count and first
item, indicates that it's working.

But, on the browser screen the listbox APPEARS empty.

Is it because of how i'm clearing out the datasource stuff?
 

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

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top