Welcome to Sign in | Help

Ajutor - ListBox VisualStudio ASP.Net

  •  03-08-2010, 2:28 PM

    Ajutor - ListBox VisualStudio ASP.Net

    Urmatoarea situatie - System.NullReferenceException: Object reference not set to an instance of an object. :
    Visual Studio 2005 ASP.Net urmatorul cod:
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    cs.Open()
    sqlfltr = "select * from complet"
    da = New SqlDataAdapter(sqlfltr, cs)
    da.Fill(ds, sqlfltr)
    dv = New DataView(ds.Tables(sqlfltr))
    lstcomplete.DataSource = dv
    lstcomplete.DataValueField = "nume"
    lstcomplete.DataTextField = "nume"
    lstcomplete.DataBind()
    End Sub

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
    txtcomplet.Text = lstcomplete.SelectedItem.Value
    End Sub

    Se populeza cu datele din baza apoi da urmatoarea eroare:
    Server Error in '/test' Application.
    --------------------------------------------------------------------------------

    Object reference not set to an instance of an object.
    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

    Source Error:
    Line 22:
    Line 23: Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
    Line 24: txtcomplet.Text = lstcomplete.SelectedItem.Value
    Line 25: End Sub
    Line 26:
    Source File: C:\Inetpub\wwwroot\test\Default.aspx.vb Line: 24

    Stack Trace:


    [NullReferenceException: Object reference not set to an instance of an object.]
    _Default.Button1_Click(Object sender, EventArgs e) in C:\Inetpub\wwwroot\test\Default.aspx.vb:24
    System.Web.UI.WebControls.Button.OnClick(EventArgs e) +78
    System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +100
    System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
    System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
    System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36
    System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2863




    --------------------------------------------------------------------------------
    Version Information: Microsoft .NET Framework Version:2.0.50727.3603; ASP.NET Version:2.0.50727.3082

    Multumesc Anticipat ma doare capul de cateva zile si nu-i dau de cap.

    P.S. Incepator in ale programatului
View Complete Thread
Powered by Community Server (Commercial Edition), by Telligent Systems