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!

Find control in formview 1

Status
Not open for further replies.

blounty

Technical User
Mar 23, 2006
46
Hi all,

I am creating a page with a multiview which has 2 views. in one view there is a dropdownlist and in the other a formview. i want to be able to apply the selecteditem text to a label in the insert template of my formview. I understand that i have to use findcontrol() which i have done and works on the first try. if i press cancel in the insert template of my formview and try again i get a NullReferenceException.

my code behind is as follows:

Code:
Partial Class Vehicles
    Inherits System.Web.UI.Page
    Protected WithEvents branchid As New Label


    Public Sub NewVehicle_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles NewVehicle.Click

        Me.VehiclesMultiView.SetActiveView(FormEdit)
        Me.FormView1.ChangeMode(FormViewMode.Insert)
        branchid = CType(FormView1.Row.FindControl("BranchID"), Label)
        branchid.Text = Me.BranchDropDown.SelectedItem.Text

    End Sub
End Class

any ideas anyone its hurting my head!

Thanks all.

 
Which line do you get the error? Did you step through your code to find the problem?
 
Code:
branchid = CType(FormView1.Row.FindControl("BranchID"), Label)
on this line, it seems the second time round the branchid is nothing?

"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning."
Rick Cook, The Wizardry Compiled
 
my experience has been that multiview views are mutually exclusive. the controls/data contained within each view are only accessible when the view is active. all other views/children are no instantiated.

This is the main difference between the multiview and the wizard control.

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top