Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / May 2008

Tip: Looking for answers? Try searching our database.

dropdown looks empty, but has item

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Cirene - 28 May 2008 16:42 GMT
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!
Manish - 28 May 2008 17:59 GMT
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

> In a certain condition I want to 'detach' a dropdownlist from it's
> datasource, clear it, and put in my own items via code.
[quoted text clipped - 20 lines]
>
> Thanks!
Cirene - 28 May 2008 18:03 GMT
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?

> Hi Cirene,
>
[quoted text clipped - 34 lines]
>>
>> Thanks!
Cirene - 29 May 2008 22:09 GMT
Any ideas on this?

> Everything, including respone.write of the listbox item count and first
> item, indicates that it's working.
[quoted text clipped - 42 lines]
>>>
>>> Thanks!

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.