dropdown looks empty, but has item

  • Thread starter Thread starter Cirene
  • Start date Start date
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!
 
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
 
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?
 
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?
 
Back
Top