[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Bilal

2/26/2004 10:11:00 AM

hi all

I am facing a little problem. I have a form with a dropdownlist control. I have a button and when i click the form posts back
The problem is that in the on button click event i'm calling this metho
------------------
Sub cute(sender As Object, e As EventArgs
Response.Write(ddlColors.SelectedItem.text
End Su

------------------
in which i'm only trying to access my dropdownlist ddlColors's selected value. It gives me this exception
---------------------------------------------------------------------------------------------
System.NullReferenceException: Object reference not set to an instance of an objec
---------------------------------------------------------------------------------------------

Please tell me what can i do about this and what am i doing wrong

thanks!
1 Answer

Sarmad Aljazrawi

2/26/2004 11:31:00 AM

0

I think that (ddlColors.SelectedItem) is nothing which giving you this
exception. Are you populating the dropdown in on page load event? check that
you are not populating it under (if not page.isPostback) because then your
dropdown will be empty.

obs: if this didn't help you, post the rest of your code and i'll help.

Regards,
--
Sarmad Aljazrawi
B.Sc. Computer Science, MSDBA, MCP
www.aljazrawi.net


"Bilal" <bsmalik@apparelco.com> wrote in message
news:7D15E861-0F16-4D12-A36B-F8A0E21BCC11@microsoft.com...
> hi all,
>
> I am facing a little problem. I have a form with a dropdownlist control. I
have a button and when i click the form posts back.
> The problem is that in the on button click event i'm calling this method
> -------------------
> Sub cute(sender As Object, e As EventArgs)
> Response.Write(ddlColors.SelectedItem.text)
> End Sub
>
> -------------------
> in which i'm only trying to access my dropdownlist ddlColors's selected
value. It gives me this exception:
> --------------------------------------------------------------------------
--------------------
> System.NullReferenceException: Object reference not set to an instance of
an object
> --------------------------------------------------------------------------
--------------------
>
> Please tell me what can i do about this and what am i doing wrong.
>
> thanks!