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

Get a handle on a dropdowlist?

Good Morning All,
How can i get a handle on this drop down list?
public void myDropDown_OnDataBinding(object sender, EventArgs e)
{
DropDownList myDropDown = (DropDownList)sender;
Debug.Write(myDropDown.SelectedItem.Value);
}

gives me an Exception Details: System.NullReferenceException: Object
reference not set to an instance of an object.
Any ideas?

Thanks,
Chris


Nov 19 '05 #1
3 930
Apparently no item is selected, thus raising the NullRefernceException.

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net
"Chris Kettenbach" <c_**********@hotmail.com> wrote in message
news:0o********************@giganews.com...
Good Morning All,
How can i get a handle on this drop down list?
public void myDropDown_OnDataBinding(object sender, EventArgs e)
{
DropDownList myDropDown = (DropDownList)sender;
Debug.Write(myDropDown.SelectedItem.Value);
}

gives me an Exception Details: System.NullReferenceException: Object
reference not set to an instance of an object.
Any ideas?

Thanks,
Chris


Nov 19 '05 #2
Likely myDropDown.SelectedItem is null?

"Chris Kettenbach" <c_**********@hotmail.com> wrote in message
news:0o********************@giganews.com...
Good Morning All,
How can i get a handle on this drop down list?
public void myDropDown_OnDataBinding(object sender, EventArgs e)
{
DropDownList myDropDown = (DropDownList)sender;
Debug.Write(myDropDown.SelectedItem.Value);
}

gives me an Exception Details: System.NullReferenceException: Object
reference not set to an instance of an object.
Any ideas?

Thanks,
Chris



Nov 19 '05 #3
it could be that the SelectedItem object is what raising the null exception..
DropDownList myDropDown = (DropDownList)sender; should be working..

by the way,

"Chris Kettenbach" wrote:
Good Morning All,
How can i get a handle on this drop down list?
public void myDropDown_OnDataBinding(object sender, EventArgs e)
{
DropDownList myDropDown = (DropDownList)sender;
Debug.Write(myDropDown.SelectedItem.Value);
}

gives me an Exception Details: System.NullReferenceException: Object
reference not set to an instance of an object.
Any ideas?

Thanks,
Chris


Nov 19 '05 #4

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

Similar topics

7
by: Tony Johansson | last post by:
Hello!! Assume I have a handle body pattern with classes called Handle and Body. In the Body class I store one int value for example 7 or some other integer value. In the Handle class I have...
2
by: Indiana Epilepsy and Child Neurology | last post by:
Before asking this questions I've spent literally _years_ reading (Meyer, Stroustrup, Holub), googling, asking more general design questions, and just plain thinking about it. I am truly unable to...
2
weaknessforcats
by: weaknessforcats | last post by:
Handle Classes Handle classes, also called Envelope or Cheshire Cat classes, are part of the Bridge design pattern. The objective of the Bridge pattern is to separate the abstraction from the...
1
ndhoan19
by: ndhoan19 | last post by:
I have two dropdowlist. dropdowlist1 and dropdowlist2. dropdowlist2 get data of dropdowlist1 .Example. data of dropdowlist2 is English Span Japan Other Now. I want to English, Span,Japan not...
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: 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...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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
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...

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.