Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help getting NewUserLink_Click button to work

Status
Not open for further replies.

twdeveloper

Programmer
Mar 8, 2011
19
US
Hello,

I have a gerneral question I was hopeing to get some help with.

I have built a page with a Tab that has user info. I have a FormView with a Gridview inside and

an ASP LinkButton to add a new user. However, when I click on the add a new user button I get an error message stating "NullReferenceException was unhandled by user code. Object Reference not set to an Instance of an Object. Then the Troubleshooting tips: Use the "new" keyword to create an object Instance. Check to determine if the Object is null before calling the method.

I just figured it was as simple as assigning a new object instance to MV = MultiView.

This is the line generating the error.

MV =wpm.Parent.FindControl"MultiViewUser")


Any help with this would be much appreciated.


The following is the code I have that is generating the error:

' User.aspx.vb

Protected Sub NewUserLink_Click(ByVal sender As Object, ByVal e As System.EventArgs)

Handles NewUserLink.Click

Dim TC As AjaxControlToolkit.TabContainer
Dim TP As AjaxControlToolkit.TabPanel
Dim FV As FormView
Dim MV As MultiView = Nothing
Dim wpm As WebPartManager
Dim LB As LinkButton

wpm = TestClassLib.FindWebPartManager(Me)

' Error on Next line
MV =wpm.Parent.FindControl"MultiViewUser")

MV.ActiveViewIndex = 1

'reset the factory vars
User__Factory.Set_ID(User__Factory.User_TABS, "UserIDLabel", "-1")
User__Factory.Set_ID(User__Factory.User_TABS, "AddressIDLabel", "-1")

'Make the ADMIN TabPanel visible and active: others not visible
TC = MV.FindControl("TC")
TP = TC.FindControl("TabPanel2")
TP.Visible = False

'Find the FormView and change it to insert mode:
FV = TestClassLib.FindControlRecursive(MV, "FV_User_Admin_General")
FV.ChangeMode(FormViewMode.Insert)
FV.DataBind()
FV.EnableViewState = True

LB = TestClassLib.FindControlRecursive(FV, "UpdateButton2")
LB.CommandName = "Insert"
LB.Text = "Insert"

End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top