asp.net - Error - Object reference not set to an instance of an object -
when run following code thows following error:
"object reference not set instance of object."
protected sub createuserwizard1_load(byval sender object, byval e system.eventargs) handles createuserwizard1.load dim sqldata new system.data.sqlclient.sqlconnection("data source=.\sqlexpress;attachdbfilename=|datadirectory|\aspnetdb.mdf;integrated security=true;user instance=true") dim cmdselect new system.data.sqlclient.sqlcommand("select top 1 employeeid a1_admins order id desc", sqldata) dim label11 label = createuserwizard1.createuserstep.contenttemplatecontainer.findcontrol("label11") sqldata.open() dim dtrreader system.data.sqlclient.sqldatareader = cmdselect.executereader() if dtrreader.hasrows while dtrreader.read() label11.text = dtrreader("employeeid") end while end if dtrreader.close() sqldata.close() end sub end class
how can fix this?
it's tough without stack trace (maybe can provide it?), guess, looking @ code following line returning null
dim label11 label = createuserwizard1.createuserstep.contenttemplatecontainer.findcontrol("label11")
and trying set it's "text" property here, though variable null (accessing property on null object)
label11.text = dtrreader("employeeid")
Comments
Post a Comment