|
List Info
Thread: Dropdownlist doesn't get recognised without selected items
|
|
| Dropdownlist doesn't get recognised
without selected items |
  Belgium |
2007-10-12 04:35:20 |
Hello,
I've been watching this list for some time to improve mijn
.net skills
and now i've encountered a problem where i can't find any
information about.
I have several dropdownlists and want to check if the
previous list has
selected items or not using followin code
if ( dropdown1.SelectedIndex <= 0)
But i get a System.NullReferenceException
On pageload i fill the dropdowns, i even set the
selectedIndex to the
first item. The code i use is in the second dropdown
autoPostback
function. But it still gives me a nullreferenceexception.
Could some help me? Thank you
--
David Duymelinck
________________
david icreate.be
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "DotNetDevelopment, VB.NET, C# .NET,
ADO.NET, ASP.NET, XML, XML Web Services,.NET Remoting"
group.
To post to this group, send email to DotNetDevelopment googlegroups.com
To unsubscribe from this group, send email to
DotNetDevelopment-unsubscribe googlegroups.com
For more options, visit this group at
http:
//cm.megasolutions.net/forums/default.aspx
-~----------~----~----~----~------~----~------~--~---
|
|
| Re: Dropdownlist doesn't get recognised
without selected items |

|
2007-10-15 07:45:01 |
How about (C#):
if ( dropdown1.SelectedIndex == null ||
dropdown1.SelectedIndex < 0)
Remember that it's zero-based
(http://msdn2.microsoft.com/en-us/library/
system.web.ui.webcontrols.drop
downlist.selectedindex.aspx) so 0 is a valid selection.
_____
Peter Smith
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "DotNetDevelopment, VB.NET, C# .NET,
ADO.NET, ASP.NET, XML, XML Web Services,.NET Remoting"
group.
To post to this group, send email to DotNetDevelopment googlegroups.com
To unsubscribe from this group, send email to
DotNetDevelopment-unsubscribe googlegroups.com
For more options, visit this group at
http:
//cm.megasolutions.net/forums/default.aspx
-~----------~----~----~----~------~----~------~--~---
|
|
| Re: Dropdownlist doesn't get recognised
without selected items |
  United States |
2007-10-15 01:57:08 |
hi,
did u check that the dropdown1 object is initialized?
Regards
Kannan.P
On Oct 12, 2:35 pm, David Duymelinck <da... icreate.be> wrote:
> Hello,
>
> I've been watching this list for some time to improve
mijn .net skills
> and now i've encountered a problem where i can't find
any information about.
>
> I have several dropdownlists and want to check if the
previous list has
> selected items or not using followin code
>
> if ( dropdown1.SelectedIndex <= 0)
>
> But i get a System.NullReferenceException
>
> On pageload i fill the dropdowns, i even set the
selectedIndex to the
> first item. The code i use is in the second dropdown
autoPostback
> function. But it still gives me a
nullreferenceexception.
>
> Could some help me? Thank you
>
> --
> David Duymelinck
> ________________
> da... icreate.be
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "DotNetDevelopment, VB.NET, C# .NET,
ADO.NET, ASP.NET, XML, XML Web Services,.NET Remoting"
group.
To post to this group, send email to DotNetDevelopment googlegroups.com
To unsubscribe from this group, send email to
DotNetDevelopment-unsubscribe googlegroups.com
For more options, visit this group at
http:
//cm.megasolutions.net/forums/default.aspx
-~----------~----~----~----~------~----~------~--~---
|
|
| Re: Dropdownlist doesn't get recognised
without selected items |
  United States |
2007-10-14 03:52:01 |
It would be better if you send the block of code where u get
the null
reference exception and also the code where you fill up the
combo box.
There are ways around to resolve null reference exception
and
gracefully handle it but you should not get that exception
at first
place looking to your description of problem.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "DotNetDevelopment, VB.NET, C# .NET,
ADO.NET, ASP.NET, XML, XML Web Services,.NET Remoting"
group.
To post to this group, send email to DotNetDevelopment googlegroups.com
To unsubscribe from this group, send email to
DotNetDevelopment-unsubscribe googlegroups.com
For more options, visit this group at http://groups.google.com/group/DotNetDevelopment?hl=en
-~----------~----~----~----~------~----~------~--~---
|
|
[1-4]
|
|