473,407 Members | 2,320 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

dropdown looks empty, but has item

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!
Jun 27 '08 #1
3 1256
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
"Cirene" wrote:
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!
Jun 27 '08 #2
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?

"Manish" <Ma****@discussions.microsoft.comwrote in message
news:FE**********************************@microsof t.com...
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
"Cirene" wrote:
>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!

Jun 27 '08 #3
Any ideas on this?

"Cirene" <ci****@nowhere.comwrote in message
news:Oi**************@TK2MSFTNGP04.phx.gbl...
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?

"Manish" <Ma****@discussions.microsoft.comwrote in message
news:FE**********************************@microsof t.com...
>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
"Cirene" wrote:
>>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!


Jun 27 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Mira Vizjak | last post by:
Hi I'm using a datagrid with a dropdown list in it. The dropdown list is filled with values from SQL database, it's autopostback property is set to true and when I select another item in it, the...
1
by: Jim Corey | last post by:
I'm thinking this problem is not specific to ASP.NET but anyway: I have a dropdown that I populate when the page loads, and I have values that are different from the text that displays, so the...
5
by: Kris Rockwell | last post by:
Hello (again), I have gotten the dropdown list functionality to work through a few tricks (probably not the most efficient, but it works) but I am not sure how to set the default selected value....
2
by: tmeister | last post by:
I must be missing something obvious. I have a drop down list in asp.net and it populates the states from a database. When I view the source of the page I get the standard option tags with the...
6
by: Paul | last post by:
I am trying to setup a field validator and tried using the control to validate set to a dropdown list box but did not seem to work. Is there anyway to set this up or do you need to use client side...
3
by: Big Dave | last post by:
I know it's been asked a million times before, but I still can't seem to find an answer that works. I've got a dropdown list in the footer template of a datagrid. The dropdown list databinds,...
1
by: Dino Buljubasic | last post by:
Hi, I have a toolbar with several buttons on it, one of which is set up to be as a DropDown button. I also have a context menu with menu items assigend to it so when I click that button, my...
2
by: Mike Collins | last post by:
I cannot get the correct drop down list value from a drop down I have on my web form. I get the initial value that was loaded in the list. It was asked by someone else what the autopostback was...
6
by: cretaceous | last post by:
Hi I'm a php/mysql developer and struggle when it comes to javascript ! I've looked all over for a solution but am rubbish at adapting javascript I've got two select dropdowns in a form The...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.