473,385 Members | 1,655 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,385 software developers and data experts.

Figuring out why a dropdownlist is considered empty

Is there a more error proof way of deciding when to try:

Dim li As ListItem
li = Me.cmbSPEC.Items.FindByValue(Session("ssSpec"))

If li IsNot Nothing Then
li.Selected = True
end if
I figured out that I was receiving the error because my dropdown list was
empty
But now on this particular non-working instance, I have appropriately filled
my dropdown list manually in several pages including the one
I want it to work on... like this:
Private Sub FillSpecs()
With Me.cmbSPEC
.DataSource = Vitals_TB.PullSpecialties
.DataTextField = "Specialty"
.DataValueField = "DeptSpecID"

.DataBind()
End With

End Sub
Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load

If Not IsPostBack Then
PI = GetLoginData()
WP = GetWorkingProvider(Session("ssWorkingProvID"))
strNUID = PI.strNUID
SecLevel = PI.strSecLevel
Session("ssNUID") = strNUID

FillSpecs()

Dim li As ListItem
li = Me.cmbSPEC.Items.FindByValue(Session("ssSpec"))
If li IsNot Nothing Then
li.Selected = True
Else
'Start the Spec with the providers spec/dept
Session.Add("ssSpec", WP.strProvDept)

'Figure out why this line is throwing a null exception

Me.cmbSPEC.Items.FindByValue(Session("ssSpec")).Se lected =
True
'I've mannually filled the combobox...
'I've checked the session variable, both are good -- so why
is it still throwing a null exception?

Me.Label1.Text = Session("ssSpec")
End If
End If

End Sub

it's strange because I have the same exact code on another page, but for
some reason its not working on this page -- what else can I examin to get to
the bottom of this?

Any reasonable suggestions would be greatly appreciated

Jun 27 '08 #1
2 1186
You might have to put the combo's loading logic within Form_Init or
Form_LoadComplete. If you search the group for something like "Combo
forgetting values" you'll find where I got the idea from.
Jun 27 '08 #2
I tried exactly that - but I still get the same error.

I also tried finding the post using 'Combo forgetting values' or 'Forgetting
values' + Combo box - and the closest article I could find was 'Dynamic
Control Creation' betwee Philip and Sameer.

Sure, putting the combo's loading logic may work in a different event, but
explain why it works normally when I use the same exact logic on another page
that is exactly the same, with the exception of the combo box's name.

I've experienced a lot of this with Microsoft. Controls "forgetting" their
values... as if you have to 'Wake' them up to make them remember.

My MainFrame friend always laughs when he finds things that have a life of
their own in Visual Studio.

"cfps.Christian" wrote:
You might have to put the combo's loading logic within Form_Init or
Form_LoadComplete. If you search the group for something like "Combo
forgetting values" you'll find where I got the idea from.
Jun 27 '08 #3

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

Similar topics

0
by: kamaumalone | last post by:
I have a dropdownlist which lives inside of a repeater. The repeater accepts user input via textboxes and the aforementioned dropdownlist. The repeater accepts phone numbers and allows for an...
0
by: Simon | last post by:
All I have a .Net 2003 webform, that contains a DropDownList databound to one table, whilst SelectedValue is databound to another table I discovered that the first time I'd load the page, the...
10
by: Sacha Korell | last post by:
I'm trying to load a drop-down list with all DropDownList control names from another page. How would I be able to find those DropDownList controls? The FindControl method will only find a...
1
by: jimb | last post by:
I can get the dropdownlist into the datagrid, and I can populate it, but I can't read it. Anybody have a working example of a dropdownlist in an editable grid? Thanks. -- .....
1
by: Anilsg | last post by:
Hi all, I have the DropDownList in the FormView,inside InsertTemplateField The data is binded in run time to it in codebehind page,FOr the First time the page is loaded the DropdownList is...
0
by: Anilsg | last post by:
Hi all, I have the DropDownList in the FormView,inside InsertTemplateField The data is binded in run time to it in codebehind page,FOr the First time the page is loaded the DropdownList...
1
by: MaryamSh | last post by:
Hi, I am creating a Dynamic Search in my application. I create a user control and in Page_load event I create a dynamic dropdownlist and 2 dynamic button (Add,Remove) By pressing Add button...
1
by: =?Utf-8?B?R3JlZw==?= | last post by:
I'm trying to set a asp:DropDownList control value to blank/null for records that have no value. But, I'm finding that even though their is no value in my source data, it displays a record from the...
0
by: asmx126453 | last post by:
Hey mensen I am having some big troubles here i tryd solving it myself with internet for 2 days but i kind fix it. Its about this i have a DotNet project that alrydi is online and working for...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.