• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 202
  • Last Modified:

Object reference not set to an instance of an object.

Can yoy guys look at this very basic code and tell my I get this error.


Line 1583:            'End If
Line 1584:
Line 1585:            If ddlCashAccount.SelectedItem.Text = "" Then
Line 1586:
Line 1587:                strScript = "<script>"


[NullReferenceException: Object reference not set to an instance of an object.]
   iVMF.wfmMain.MissingRequiredFields() in c:\inetpub\wwwroot\VB\iVMF\wfmMain.aspx.vb:1585
   iVMF.wfmMain.btnVMSave_Click(Object sender, EventArgs e) in c:\inetpub\wwwroot\VB\iVMF\wfmMain.aspx.vb:1895
   System.Web.UI.WebControls.Button.OnClick(EventArgs e)
   System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
   System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
   System.Web.UI.Page.ProcessRequestMain()






If ddlCashAccount.SelectedItem.Text = "" Then

                strScript = "<script>"

                strScript = strScript & "alert('Invaild Cash Account! Cash Account is mandatory on Vendor Company tab.');"

                strScript = strScript & "</script>"

                Page.RegisterStartupScript("ClientScript", strScript.ToString())

                Exit Function
            End If


I seem to be getting alot of these errors

6784

0
6784
Asked:
6784
1 Solution
 
DabasCommented:
Hi 6784:

Probably ddlCashAccount has no selected item yet. Hence ddlCashAccount.SelectedItem is nothing, hence hte exception.

Try the following instead:

If not ddlCashAccount.SelectedItem is Nothing then
        ...

Dabas
0
 
6784Author Commented:
Dabas,

Yes, that could very well be the problem. I'm stepping through the vaildation code, without entering any data or selecting any items in the ddls.

Thanks for the quick response.

6784
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now