#31
  1. Contributing User
    ASP Discoverer (100 - 499 posts)

    Join Date
    Jan 2006
    Posts
    238
    Rep Power
    25
    Originally Posted by jmurrayhead
    Just to add to the above, to reference the "buried" control do such:

    vb.net Code:
     
        Private Sub Page_Load(sender As Object, e As EventArgs)
            Dim testIDtxt As TextBox
            testIDtxt = Repeater1.Controls.(0).FindControl("testID")
            testIDtxt.Text = "this WILL work"
        End Sub


    Written in VB, but same concept.
    Is this line correct?
    testIDtxt = Repeater1.Controls.(0).FindControl("testID")
    I tried to c&p it, but Intellisense doesn't accept:
    Repeater1.Controls.(0).FindControl("testID")
    Repeater1.Controls(0).FindControl("testID")
    Repeater1.Controls.FindControl("testID")
    ...
  2. #32
  3. No Profile Picture
    Registered User
    ASP Explorer (0 - 99 posts)

    Join Date
    Nov 2008
    Posts
    8
    Rep Power
    0
    Originally Posted by imbrod
    Is this line correct?
    testIDtxt = Repeater1.Controls.(0).FindControl("testID")
    I tried to c&p it, but Intellisense doesn't accept:
    Repeater1.Controls.(0).FindControl("testID")
    Repeater1.Controls(0).FindControl("testID")
    Repeater1.Controls.FindControl("testID")
    ...
    Howzit,

    where there are curved brackets in VB you usually need square ones in C# when dealing with references. So your code would be more like:

    testIDtxt = Repeater1.Controls[0].FindControl("testID");
    Repeater1.Controls[0].FindControl("testID");

    Here's a link to help you in the future. You've got to be very careful using these converters though as they can really put you in a world of hurt if you just copy paste a lot of code.

    Search for "CodeTranslator: Free Code Translation From VB.NET <-> C#". I can't post the link cause i'm a new user.
  4. #33
  5. No Profile Picture
    Registered User
    ASP Explorer (0 - 99 posts)

    Join Date
    Nov 2008
    Posts
    1
    Rep Power
    0

    Question Object reference not set to an instance of an object


    I am connected to a ERP System Vantage table QuoteDtl. The code below is my attempt to update an existing QuoteDtl Record i.e., Line one (QuoteDtl) of the QuoteHed (Quote Header) record.

    Dim edvCompany As EpiDataView = CType(oTrans.EpiDataViews("QuoteDtl"), EpiDataView) <<< QuoteDtl is a PROGRESS Table in Vantage ERP System
    Dim dvOrdRel As DataView = edvCompany.dataView
    MessageBox.Show("After DIMS" & xlsDatei ) << I see this message

    Dim drv As DataRowView
    MessageBox.Show("B4 Update" & xlsDatei ) <<< I See This Message
    <<<< *** ERROR Object reference not set to an instance of an object.

    'drv("RowMod") = "A"
    drv("Company") = "HS"
    drv("QuoteNum") = 14357
    drv("QuoteLine") = 1
    drv("CustNum") = 11
    drv("PartNum") = "*03-0199"
    drv("LineDesc") = "*03-0199 Description"
    drv("OrderQty") = 0
    drv("Number01") = 3
    drv("revisionNum") = "B-1"
    drv("ProdCode") = "Dominica"
    drv("SellingExpFactor") = 1
    drv("Confidencepct") = 0
    MessageBox.Show("After Field Sets" )
    oTrans.Update()
  6. #34
  7. No Profile Picture
    Registered User
    ASP Explorer (0 - 99 posts)

    Join Date
    Mar 2009
    Posts
    7
    Rep Power
    0

    I need help


    I am new to .net I am having an issue with Object reference not set to instance of an object.
    What i am trying to do is fill a label with data from my SQL db an example of what i have is
    Dim TA as new StyleDataTableAdpters.StyleTableAdtpter()
    Dim ID As Integer=StyleDDL.SelectedValue
    Dim Height as String
    Height=TA.HeightByID(ID)
    Heightlbl.Text= Height

    now this is part of a web form, For composing online fence estimates basically the user selects there fence style and the details of the style are set into the labels. I have debugged and in the watch it the error is in my insert But the look shows that all my insert parameters have data and none are null so I'm assuming that the code example above is the source to my error. I'm sorry if this is not clear I have only been doing this for a few months any help is appreciated. Thank You
  8. #35
  9. Moderator From Beyond
    ASP Mastermind (5000+ posts)

    Join Date
    Sep 2004
    Location
    Israel
    Posts
    31,135
    Rep Power
    2926
    the only candidate for null here is this:
    StyleDDL.SelectedValue
    check in debug mode what is the selected value of your drop down list.

    if no luck, error messages of .NET always come with Stack Trace.. post it
    here and we'll help you track down the source of that error.
  10. #36
  11. No Profile Picture
    Registered User
    ASP Explorer (0 - 99 posts)

    Join Date
    Mar 2009
    Posts
    7
    Rep Power
    0
    the styleDDL is not null it has a value, in debug mode all my parameters have sufficient data, nothing is null. My insert method i am using is successful in several other pages of my project. it only seems to be this page and one other page, and both pages I am using the same method to fill labels and get data from db for the labels. Maybe I will try another method of getting Data.
  12. #37
  13. No Profile Picture
    Registered User
    ASP Explorer (0 - 99 posts)

    Join Date
    Mar 2009
    Posts
    7
    Rep Power
    0
    Originally Posted by Shadow Wizard
    the only candidate for null here is this:
    StyleDDL.SelectedValue
    check in debug mode what is the selected value of your drop down list.

    if no luck, error messages of .NET always come with Stack Trace.. post it
    here and we'll help you track down the source of that error.
    This is the Stack Trace
    Hope this is what you need.
    [NullReferenceException: Object reference not set to an instance of an object.]
    _Default.SubmitBtn_Click(Object sender, EventArgs e) in C:\Users\John\Documents\Visual Studio 2008\WebSites\MyProject\FenceEstimate.aspx.vb:96
    System.Web.UI.WebControls.Button.OnClick(EventArgs e) +111
    System.Web.UI.WebControls.Button.RaisePostBackEven t(String eventArgument) +110
    System.Web.UI.WebControls.Button.System.Web.UI.IPo stBackEventHandler.RaisePostBackEvent(String eventArgument) +10
    System.Web.UI.Page.RaisePostBackEvent(IPostBackEve ntHandler sourceControl, String eventArgument) +13
    System.Web.UI.Page.RaisePostBackEvent(NameValueCol lection postData) +36
    System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565
  14. #38
  15. Moderator From Beyond
    ASP Mastermind (5000+ posts)

    Join Date
    Sep 2004
    Location
    Israel
    Posts
    31,135
    Rep Power
    2926
    what is line 96 of the file FenceEstimate.aspx.vb?
    also please post code for SubmitBtn_Click method from that file.
  16. #39
  17. No Profile Picture
    Registered User
    ASP Explorer (0 - 99 posts)

    Join Date
    Mar 2009
    Posts
    7
    Rep Power
    0
    Originally Posted by Shadow Wizard
    what is line 96 of the file FenceEstimate.aspx.vb?
    also please post code for SubmitBtn_Click method from that file.
    Protected Sub SubmitBtn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles SubmitBtn.Click
    ----->this in bold is line 96 Dim Save As FenceEstimate = Nothing "This FenceEtimate is a Vb class Called FenceEstimate it is where i defined the insert parameters"
    Dim poop As Boolean = False 'I know im in poop if this stays false.
    Save = New FenceEstimate(txtDate.Text, txtFname.Text, txtLName.Text, txtAdd1.Text, txtAdd2.Text, CitysDDL.SelectedValue, txtEmail.Text, txtPhone.Text, txtPhone2.Text, Stylelbl.Text, HeightLable.Text, txtLength.Text, txtLengthRemaove.Text, EarthDDL.SelectedItem.Text, SurfaceDDL.SelectedItem.Text, GradeDDL.SelectedItem.Text, FenceLineDDL.SelectedItem.Text, GatesDDL.SelectedItem.Text, Gate1DDL.SelectedItem.Text, Gate2DDL.SelectedItem.Text, Gate3DDL.SelectedItem.Text, WoodTypeLabel.Text, CapLabel.Text, txtCompleteDate.Text, InHomeDDL.SelectedValue, LabTotlbl.Text, MatTotlbl.Text, TotCostlbl.Text, Statuslbl.Text)
    poop = Save.InsertToDB()
    ------------------------------------------------------------
    This is the entire App_Code FenceEstimate VB Page
    Public Class FenceEstimate
    Public DateOfEst As String = ""
    Public F_Name As String = ""
    Public L_Name As String = "'"
    Public Address1 As String = ""
    Public Address2 As String = ""
    Public City As String = ""
    Public Email As String = ""
    Public Phone As String = ""
    Public Phone2 As String = ""
    Public Style As String = ""
    Public Height As String = ""
    Public Length As String = ""
    Public LengthRemove As String = ""
    Public Earth As String = ""
    Public Surface As String = ""
    Public Level As String = ""
    Public FenceLine As String = ""
    Public NumGates As String = ""
    Public Gate1 As String = ""
    Public Gate2 As String = ""
    Public Gate3 As String = ""
    Public WoodType As String = ""
    Public CapStyle As String = ""
    Public DateBy As String = ""
    Public InHome As String = ""
    Public EstLabor As String = ""
    Public EstMat As String = ""
    Public EstTot As String = ""
    Public Status As String = ""
    Dim TA As New FenceStylesTableAdapters.FenceEstimatesTableAdapte r()

    Public Sub New(ByVal DateOfEst As String, ByVal F_Name As String, ByVal L_Name As String, ByVal Address1 As String, ByVal Address2 As String, ByVal City As String, ByVal Email As String, ByVal Phone As String, ByVal Phone2 As String, ByVal Style As String, ByVal Height As String, ByVal Length As String, ByVal LengthRemove As String, ByVal Earth As String, ByVal Surface As String, ByVal Level As String, ByVal FenceLine As String, ByVal NumGates As String, ByVal Gate1 As String, ByVal Gate2 As String, ByVal Gate3 As String, ByVal WoodType As String, ByVal CapStyle As String, ByVal DateBy As String, ByVal InHome As String, ByVal EstLabor As String, ByVal EstMat As String, ByVal EstTotal As String, ByVal Status As String)
    Me.DateOfEst = DateOfEst
    Me.F_Name = F_Name
    Me.L_Name = L_Name
    Me.Address1 = Address1
    Me.Address2 = Address2
    Me.City = City
    Me.Email = Email
    Me.Phone = Phone
    Me.Phone2 = Phone2
    Me.Style = Style
    Me.Height = Height
    Me.Length = Length
    Me.LengthRemove = LengthRemove
    Me.Earth = Earth
    Me.Surface = Surface
    Me.Level = Level
    Me.FenceLine = FenceLine
    Me.NumGates = NumGates
    Me.Gate1 = Gate1
    Me.Gate2 = Gate2
    Me.Gate3 = Gate3
    Me.WoodType = WoodType
    Me.CapStyle = CapStyle
    Me.DateBy = DateBy
    Me.InHome = InHome
    Me.EstLabor = EstLabor
    Me.EstMat = EstMat
    Me.EstTot = EstTot
    Me.Status = Status
    End Sub
    Public Function InsertToDB() As Boolean
    Dim Save As Integer
    Save = TA.InsertEstimate(DateOfEst, F_Name, L_Name, Address1, Address2, City, Email, Phone, Phone2, Style, Height, Length, LengthRemove, Earth, Surface, Level, FenceLine, NumGates, Gate1, Gate2, Gate3, WoodType, CapStyle, DateBy, InHome, EstLabor, EstMat, EstTot, Status)
    If Save > 0 Then
    Return True
    Else
    Return False
    End If
    End Function
    End Class

    Appreciate the help thanks this is my first site is complete all but theses errors.
    Also I see in the stack trace it is referencing to postData(second line from bottom of stack trace) I was at one point attempting to write a Public Sub Called postData which was meant to be used to fill the labels with Data from DB but i deleted that. I think that may have something to do with it. Thanks for the help it is appreciated
  18. #40
  19. No Profile Picture
    Registered User
    ASP Explorer (0 - 99 posts)

    Join Date
    Mar 2009
    Posts
    7
    Rep Power
    0
    if you need any more info just ask once again i really appreciate the help.
  20. #41
  21. Moderator From Beyond
    ASP Mastermind (5000+ posts)

    Join Date
    Sep 2004
    Location
    Israel
    Posts
    31,135
    Rep Power
    2926
    sorry, but if you insist your drop down lists have selected item which is not null,
    I fear we're at dead end..
  22. #42
  23. No Profile Picture
    Registered User
    ASP Explorer (0 - 99 posts)

    Join Date
    Mar 2009
    Posts
    7
    Rep Power
    0
    I think so too. I am by far a programmer, and dont know too much this is my first project, before this i didnt even know html. Do you have any suggestions on aother method of placin data from a DB table into labels. thanks
  24. #43
  25. Moderator From Beyond
    ASP Mastermind (5000+ posts)

    Join Date
    Sep 2004
    Location
    Israel
    Posts
    31,135
    Rep Power
    2926
    Originally Posted by RookieJohn
    I think so too. I am by far a programmer, and dont know too much this is my first project, before this i didnt even know html. Do you have any suggestions on aother method of placin data from a DB table into labels. thanks
    not out of my sleeve, sorry. feel free to start new thread regarding this
    issue and you're likely to get good help in there.
  26. #44
  27. No Profile Picture
    Registered User
    ASP Explorer (0 - 99 posts)

    Join Date
    May 2010
    Posts
    3
    Rep Power
    0

    blarg.


    Hey, Nope I am not a programmer at all. I have this gps logger software that was working fine in xp, then one day it began to give me the object reference error, then gives me a lengthy error screen
    object reference not set to an instance of an object.system.data at system.data.datatablecollection.internalindexof(st ring tablename)
    at system.data.datatablecollection.get_item(string name)
    at gisteqlogger.form1.pnckpb0B4()
    at gisteqlogger.form1..ctor()
    at main(string[] args)system.nullreferenceException: Object reference not set to an instance of an object.
    at system.data.dattablecollection.internalindexof(str ingtablename)
    at system.data.datatablecollection.get_item(string name)
    at gisteqlogger.form1.PnckPb0B4()
    at gisteqlogger.form1..ctor()
    at main(string[]args)

    that was fun to type (not) So after many calls to the tech, he says its a window error message and does not know why it is happening. They sent me a new database file to drop in the program folder, same error. I know this program uses microsoft.net framework, and A few weeks ago I installed another program (dvd architect) that needed and installed the .net framework and it was a few days after that this gps logger stopped working. Last night I looked in add\remove programs and saw I have the .net 1, 2, 3, 3.5, and the version 4. I uninstalled all of them, rebooted, installed just the version 4. Same error. Does anyone have a clue as to what the heck is going on?
  28. #45
  29. Moderator From Beyond
    ASP Mastermind (5000+ posts)

    Join Date
    Sep 2004
    Location
    Israel
    Posts
    31,135
    Rep Power
    2926
    without source code we're practically helpless and can only guess.

    if you can convince them to give you the source code of the program it would
    be great, but chances for that are very very slim.

    my guess is that something went wrong with the database.. are you sure
    you put what you got from them (new database file) in the right place?

Similar Threads

  1. error: object reference not set to an instance of an object
    By aliaga61 in forum .NET Development
    Replies: 4
    Last Post: January 11th, 2005, 12:25 PM
  2. Replies: 0
    Last Post: August 20th, 2004, 08:18 AM
  3. Error: Object reference not set to an instance of an object.
    By zappa_justin in forum .NET Development
    Replies: 6
    Last Post: July 30th, 2004, 02:39 PM
  4. Error - Object reference not set to an instance of an object
    By ajegopinath in forum .NET Development
    Replies: 0
    Last Post: April 28th, 2004, 12:28 AM
  5. Replies: 8
    Last Post: December 29th, 2003, 12:17 AM

IMN logo majestic logo threadwatch logo seochat tools logo